Example #1
0
        public RegisterRequest(Reception reception)
        {
            Expires = 1800;//デフォルト値

            To = new SipUri(reception.Header.GetVal("To"));
            From = new SipUri(reception.Header.GetVal("From"));
            var contact = reception.Header.GetVal("Contact");
            Contact = new SipUri(contact);
            if (contact != null){
                var index = contact.IndexOf(";");
                if (index != -1){
                    var tmp = contact.Substring(index + 1);
                    var i = tmp.ToLower().IndexOf("expires");
                    if (i != -1){
                        var expires = tmp.Substring(i+8);
                        var result = 0;
                        if (Int32.TryParse(expires, out result)){
                            Expires = result;
                        }
                    }
                }
            }
            var s = reception.Header.GetVal("Expires");
            if (s != null){
                var result = 0;
                if (Int32.TryParse(s, out result)) {
                    Expires = result;
                }
            }

            Server = reception.StartLine.RequestUri;
        }
Example #2
0
        //接続単位の処理
        override protected void OnSubThread(SockObj sockObj)
        {
            var sockUdp = (SockUdp)sockObj;

            //受信データの解析
            var reception = new Reception(sockUdp.RecvBuf);

            //スタートラインの形式に問題がある
            if (reception.StartLine.ReceptionKind == ReceptionKind.Unknown)
            {
                //Logger
                return;
            }
            //未対応のSIPバージョン
            if (reception.StartLine.SipVer.No != 2.0)
            {
                //Logger
                return;
            }
            //リクエストの処理
            if (reception.StartLine.ReceptionKind == ReceptionKind.Request)
            {
                //Logger(詳細) リクエスト受信をプリント

                switch (reception.StartLine.SipMethod)
                {
                case SipMethod.Register:
                    var jobRegister = new JobRegister(_user);
                    break;

                case SipMethod.Invite:
                    break;
                }
                if (reception.StartLine.SipMethod == SipMethod.Invite)
                {
                    var oneCall = new OneCall();
                    //oneCall.Invite(lines);
                }
            }
            else   //ステータスの処理
                   //Logger(詳細) ステータス受信をプリント

            {
            }



            //このメソッドを抜けると切断される
        }
Example #3
0
        //接続単位の処理
        protected override void OnSubThread(SockObj sockObj)
        {
            var sockUdp = (SockUdp)sockObj;

            //受信データの解析
            var reception = new Reception(sockUdp.RecvBuf);

            //スタートラインの形式に問題がある
            if (reception.StartLine.ReceptionKind == ReceptionKind.Unknown) {
                //Logger
                return;
            }
            //未対応のSIPバージョン
            if (reception.StartLine.SipVer.No != 2.0) {
                //Logger
                return;
            }
            //リクエストの処理
            if (reception.StartLine.ReceptionKind == ReceptionKind.Request) {

                //Logger(詳細) リクエスト受信をプリント

                switch (reception.StartLine.SipMethod) {
                    case SipMethod.Register:
                        var jobRegister = new JobRegister(_user);
                        break;
                    case SipMethod.Invite:
                        break;

                }
                if (reception.StartLine.SipMethod == SipMethod.Invite) {
                    var oneCall = new OneCall();
                    //oneCall.Invite(lines);
                }

            } else{//ステータスの処理
                //Logger(詳細) ステータス受信をプリント

            }

            //このメソッドを抜けると切断される
        }
Example #4
0
        public RegisterRequest(Reception reception)
        {
            Expires = 1800;//デフォルト値

            To   = new SipUri(reception.Header.GetVal("To"));
            From = new SipUri(reception.Header.GetVal("From"));
            var contact = reception.Header.GetVal("Contact");

            Contact = new SipUri(contact);
            if (contact != null)
            {
                var index = contact.IndexOf(";");
                if (index != -1)
                {
                    var tmp = contact.Substring(index + 1);
                    var i   = tmp.ToLower().IndexOf("expires");
                    if (i != -1)
                    {
                        var expires = tmp.Substring(i + 8);
                        var result  = 0;
                        if (Int32.TryParse(expires, out result))
                        {
                            Expires = result;
                        }
                    }
                }
            }
            var s = reception.Header.GetVal("Expires");

            if (s != null)
            {
                var result = 0;
                if (Int32.TryParse(s, out result))
                {
                    Expires = result;
                }
            }

            Server = reception.StartLine.RequestUri;
        }
Example #5
0
 private RegisterRequest Create(int n)
 {
     var reception = new Reception((new TestLines()).Register(n));
     return new RegisterRequest(reception);
 }