当前位置: 首页>>代码示例>>C#>>正文


C# UserAgent.SendRequest方法代码示例

本文整理汇总了C#中SIPLib.SIP.UserAgent.SendRequest方法的典型用法代码示例。如果您正苦于以下问题:C# UserAgent.SendRequest方法的具体用法?C# UserAgent.SendRequest怎么用?C# UserAgent.SendRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SIPLib.SIP.UserAgent的用法示例。


在下文中一共展示了UserAgent.SendRequest方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
        }
开发者ID:CivilPol,项目名称:IMS-Services,代码行数:22,代码来源:SIPApp.cs

示例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);
 }
开发者ID:CivilPol,项目名称:IMS-Services,代码行数:10,代码来源:SIPApp.cs

示例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);
 }
开发者ID:CivilPol,项目名称:IMS-Services,代码行数:9,代码来源:SIPApp.cs

示例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);
        }
开发者ID:CivilPol,项目名称:IMS-Services,代码行数:27,代码来源:Server.cs

示例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);
            }
        }
开发者ID:CivilPol,项目名称:Sharp-IMS-Client,代码行数:13,代码来源:SIPApp.cs

示例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");
 }
开发者ID:CivilPol,项目名称:IMS-Services,代码行数:20,代码来源:Server.cs

示例7: Register

 public void Register(string username, string password, string realm)
 {
     Username = username;
     Password = password;
     Realm = realm;
     RegisterUA = new UserAgent(Stack);
     Message registerMsg = RegisterUA.CreateRegister(new SIPURI("sip:"+username+"@"+realm));
     registerMsg.InsertHeader(new Header("3600", "Expires"));
     RegisterUA.SendRequest(registerMsg);
 }
开发者ID:CivilPol,项目名称:Sharp-IMS-Client,代码行数:10,代码来源:SIPApp.cs

示例8: 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");
     }
 }
开发者ID:CivilPol,项目名称:Sharp-IMS-Client,代码行数:17,代码来源:SIPApp.cs

示例9: 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);
 }
开发者ID:richardspiers,项目名称:Sharp-IMS-Client,代码行数:8,代码来源:Presence_Handler.cs

示例10: 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);
 }
开发者ID:CivilPol,项目名称:IMS-Services,代码行数:33,代码来源:Program.cs

示例11: 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"));
     }
 }
开发者ID:richardspiers,项目名称:USPS,代码行数:29,代码来源:SIPHandler.cs


注:本文中的SIPLib.SIP.UserAgent.SendRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。