Exemple #1
0
        /// <summary>
        /// 查询设备目录请求
        /// </summary>
        /// <returns></returns>
        private SIPRequest QueryItems(SIPEndPoint remoteEndPoint, string remoteSIPId)
        {
            string fromTag = CallProperties.CreateNewTag();
            string toTag   = CallProperties.CreateNewTag();
            int    cSeq    = CallProperties.CreateNewCSeq();
            string callId  = CallProperties.CreateNewCallId();

            SIPURI        remoteUri = new SIPURI(RemoteSIPId, RemoteEndPoint.ToHost(), "");
            SIPURI        localUri  = new SIPURI(LocalSIPId, LocalEndPoint.ToHost(), "");
            SIPFromHeader from      = new SIPFromHeader(null, localUri, fromTag);
            //SIPToHeader to = new SIPToHeader(null, remoteUri, toTag);
            SIPToHeader to         = new SIPToHeader(null, remoteUri, null);
            SIPRequest  catalogReq = Transport.GetRequest(SIPMethodsEnum.MESSAGE, remoteUri);

            catalogReq.Header.From        = from;
            catalogReq.Header.Contact     = null;
            catalogReq.Header.Allow       = null;
            catalogReq.Header.To          = to;
            catalogReq.Header.UserAgent   = UserAgent;
            catalogReq.Header.CSeq        = cSeq;
            catalogReq.Header.CallId      = callId;
            catalogReq.Header.ContentType = "application/MANSCDP+xml";

            return(catalogReq);
        }
Exemple #2
0
        /// <summary>
        /// 向上级平台注册
        /// </summary>
        private void RegisterToPlatform()
        {
            string fromTag = CallProperties.CreateNewTag();
            string callId  = CallProperties.CreateNewCallId();
            int    cSeq    = CallProperties.CreateNewCSeq();
            string branch  = CallProperties.CreateBranchId();

            SIPURI     localUri    = new SIPURI(LocalSIPId, LocalEndPoint.ToHost(), "");
            SIPURI     remoteUri   = new SIPURI(RemoteSIPId, RemoteEndPoint.ToHost(), "");
            SIPRequest registerReq = new SIPRequest(SIPMethodsEnum.REGISTER, remoteUri);

            SIPViaHeader via    = new SIPViaHeader(LocalEndPoint, branch);
            SIPViaSet    viaSet = new SIPViaSet();

            viaSet.PushViaHeader(via);

            SIPFromHeader from   = new SIPFromHeader(null, localUri, fromTag);
            SIPToHeader   to     = new SIPToHeader(null, localUri, null);
            SIPHeader     header = new SIPHeader(from, to, cSeq, callId);

            registerReq.Header = header;

            SIPContactHeader contact = new SIPContactHeader(null, localUri);

            header.Contact = new List <SIPContactHeader>();
            header.Contact.Add(contact);

            header.Vias = viaSet;

            header.AuthenticationHeader = _auth;

            header.Expires       = 3600;
            header.CSeqMethod    = SIPMethodsEnum.REGISTER;
            header.MaxForwards   = 70;
            header.ContentLength = 0;
            header.UserAgent     = SIPConstants.SIP_SERVER_STRING;
            Transport.SendRequest(RemoteEndPoint, registerReq);
        }