本文整理汇总了C#中SIPLib.SIP.UserAgent.CreateRequest方法的典型用法代码示例。如果您正苦于以下问题:C# UserAgent.CreateRequest方法的具体用法?C# UserAgent.CreateRequest怎么用?C# UserAgent.CreateRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIPLib.SIP.UserAgent
的用法示例。
在下文中一共展示了UserAgent.CreateRequest方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Publish
internal void Publish(string sipUri, string basic, string note, int expires)
{
UserAgent pua = new UserAgent(Stack) { LocalParty = PublicServiceIdentity, RemoteParty = new Address(sipUri) };
Useragents.Add(pua);
Message request = pua.CreateRequest("PUBLISH");
request.InsertHeader(new Header("presence", "Event"));
request.InsertHeader(new Header(pua.LocalParty.ToString(), "P-Preferred-Identity"));
request.InsertHeader(new Header("application/pidf+xml", "Content-Type"));
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
sb.Append("<presence xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:im=\"urn:ietf:params:xml:ns:pidf:im\" entity=\"" + sipUri + "\">\n");
sb.Append("<tuple id=\"Sharp_IMS_Client\">\n");
sb.Append("<status>\n");
sb.Append("<basic>" + basic + "</basic>\n");
sb.Append("</status>\n");
sb.Append("<note>" + note + "</note>\n");
sb.Append("</tuple>\n");
sb.Append("</presence>\n");
request.Body = sb.ToString();
pua.SendRequest(request);
}
示例2: SendInvite
public void SendInvite(string uri, SDP sdp)
{
uri = checkURI(uri);
UserAgent cua = new UserAgent(Stack) { LocalParty = PublicServiceIdentity, RemoteParty = new Address(uri) };
Useragents.Add(cua);
Message invite = cua.CreateRequest("INVITE");
invite.InsertHeader(new Header("application/sdp", "Content-Type"));
invite.Body = sdp.ToString();
cua.SendRequest(invite);
}
示例3: SendMessage
public void SendMessage(string uri, string message, string contentType = "text/plain")
{
uri = checkURI(uri);
UserAgent mua = new UserAgent(Stack) { LocalParty = PublicServiceIdentity, RemoteParty = new Address(uri) };
Useragents.Add(mua);
Message m = mua.CreateRequest("MESSAGE", message);
m.InsertHeader(new Header(contentType, "Content-Type"));
mua.SendRequest(m);
}
示例4: UpdateServiceMetrics
private static void UpdateServiceMetrics(Dictionary<string, float> metrics)
{
UserAgent pua = new UserAgent(_app.Stack)
{
RemoteParty = new Address("<sip:" + ServerURI + ">"),
LocalParty = _localParty
};
Message request = pua.CreateRequest("PUBLISH");
request.InsertHeader(new Header("service-description", "Event"));
request.InsertHeader(new Header("application/SERV_DESC+xml", "Content-Type"));
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("Resources/ServiceDescription.xml");
XmlNode node = xmlDoc.SelectSingleNode("Service/Metrics/TotalCPU");
node.InnerText = String.Format("{0:0.##}", metrics["totalCPU"]);
node = xmlDoc.SelectSingleNode("Service/Metrics/CPU");
node.InnerText = String.Format("{0:0.##}", metrics["cpu"]);
node = xmlDoc.SelectSingleNode("Service/Metrics/TotalMemory");
node.InnerText = String.Format("{0:0.##}", metrics["memAvailable"]) + " MB";
node = xmlDoc.SelectSingleNode("Service/Metrics/Memory");
node.InnerText = String.Format("{0:0.##}", ((metrics["memUsed"] / 1024) / 1024)) + " MB";
request.Body = xmlDoc.OuterXml;
pua.SendRequest(request);
}
示例5: SendIM
public void SendIM(string uri, string message,string contentType = "text/plain")
{
uri = checkURI(uri);
if (IsRegistered())
{
UserAgent mua = new UserAgent(Stack) {LocalParty = RegisterUA.LocalParty, RemoteParty = new Address(uri)};
Useragents.Add(mua);
Message m = mua.CreateRequest("MESSAGE", message);
m.InsertHeader(new Header(contentType, "Content-Type"));
mua.SendRequest(m);
}
}
示例6: PublishService
private static void PublishService(bool determineIP, int port)
{
UserAgent pua = new UserAgent(_app.Stack) { RemoteParty = new Address("<sip:" + ServerURI + ">"), LocalParty = _localParty };
Message request = pua.CreateRequest("PUBLISH");
request.InsertHeader(new Header("service-description", "Event"));
request.InsertHeader(new Header("application/SERV_DESC+xml", "Content-Type"));
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("Resources/ServiceDescription.xml");
if (determineIP)
{
XmlNode IPnode = xmlDoc.SelectSingleNode("Service/Service_Config/Server_IP");
IPnode.InnerText = _localIP;
}
XmlNode Portnode = xmlDoc.SelectSingleNode("Service/Service_Config/Server_Port");
Portnode.InnerText = Convert.ToString(port);
xmlDoc.Save("Resources/ServiceDescription.xml");
request.Body = xmlDoc.OuterXml;
pua.SendRequest(request);
ConsoleLog.Info("Sent service information to SRS");
}
示例7: Invite
public void Invite(string uri, SDP sdp)
{
uri = checkURI(uri);
if (IsRegistered())
{
UserAgent cua = new UserAgent(Stack) { LocalParty = RegisterUA.LocalParty, RemoteParty = new Address(uri) };
Useragents.Add(cua);
Message invite = cua.CreateRequest("INVITE");
invite.InsertHeader(new Header("application/sdp", "Content-Type"));
invite.Body= sdp.ToString();
cua.SendRequest(invite);
}
else
{
Log.Error("isRegistered failed in invite message");
}
}
示例8: Subscribe
public void Subscribe(string sipUri)
{
UserAgent pua = new UserAgent(_app.Stack)
{RemoteParty = new Address(sipUri), LocalParty = _app.RegisterUA.LocalParty};
Message request = pua.CreateRequest("SUBSCRIBE");
request.InsertHeader(new Header("presence", "Event"));
pua.SendRequest(request);
}
示例9: PublishService
private static void PublishService(bool determineIP, int port)
{
UserAgent pua = new UserAgent(_app.Stack)
{
RemoteParty = new Address("<sip:[email protected]>"),
LocalParty = _localparty
};
Message request = pua.CreateRequest("PUBLISH");
request.InsertHeader(new Header("service-description", "Event"));
request.InsertHeader(new Header("application/SERV_DESC+xml", "Content-Type"));
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("Resources/ServiceDescription.xml");
if (determineIP)
{
XmlNode ipNode = xmlDoc.SelectSingleNode("Service/Service_Config/Server_IP");
if (ipNode == null)
{
Log.Error("Service XML does not contain Server IP node");
return;
}
ipNode.InnerText = _localIP;
}
XmlNode portNode = xmlDoc.SelectSingleNode("Service/Service_Config/Server_Port");
if (portNode == null)
{
Log.Error("Service XML does not contain Server Port node");
return;
}
portNode.InnerText = Convert.ToString(port);
xmlDoc.Save("Resources/ServiceDescription.xml");
request.Body = xmlDoc.OuterXml;
pua.SendRequest(request);
}
示例10: SendServicesChains
private void SendServicesChains(object sender, ElapsedEventArgs e)
{
DataTable serviceFlows = ReadServiceFlowDB();
bool updateNeeded = false;
if (serviceFlows == null) return;
Dictionary<string, List<ServiceFlow>> changedFlows = new Dictionary<string, List<ServiceFlow>>();
foreach (DataRow r in serviceFlows.Rows)
{
DateTime t2 = Convert.ToDateTime(r["LastUpdatedDate"].ToString());
if (_lastupdate >= t2) continue;
changedFlows[r["email"].ToString()] =
r["PropertyValuesString"].ToString().UnzipAndDeserialize<List<ServiceFlow>>();
updateNeeded = true;
}
if (updateNeeded)
{
UserAgent serviceChainUA = new UserAgent(_app.Stack)
{
RemoteParty = new Address("<sip:[email protected]>"),
LocalParty = _localparty
};
_app.Useragents.Add(serviceChainUA);
Message m = serviceChainUA.CreateRequest("MESSAGE", changedFlows.SerializeAndZip());
m.InsertHeader(new Header("APPLICATION/SERV_DESC+XML", "Content-Type"));
serviceChainUA.SendRequest(m);
_lastupdate = DateTime.Now;
//request.InsertHeader(new Header("service.description", "Event"));
}
}