예제 #1
0
 public Request(string method, SipUri uri, string version)
 {
     Method = method;
     Uri = uri;
     SipVersion = version;
     MaxForwards = -1;
 }
예제 #2
0
 static TestConstants()
 {
     BobProxyUri = new SipAddressFactory().CreateUri("", "p2.biloxi.com");
     BobProxyUri.IsLooseRouting = true;
     AliceProxyUri = new SipAddressFactory().CreateUri("", "p1.atlanta.com");
     AliceProxyUri.IsLooseRouting = true;
 }
 protected override void When()
 {
     var call = _phone.CreateCall();
     _toUri = TestConstants.EndPoint1Uri;
     call.Start(_toUri.FormatToString());
     _waitingforInviteReceived.WaitOne();
 }
예제 #4
0
 public void Add(SipUri uri, string authenticationUserName)
 {
     // using unique user names.
     var reg = new Registration();
     reg.Uri = uri;
     _authenticationIndex.Add(authenticationUserName, reg);
     _registrations.Add(uri.ToString(), reg);
 }
예제 #5
0
 public PhoneCall(SoftPhone softPhone, bool isIncoming, SipUri from, ICommand acceptCommand, ICommand rejectCommand, ICommand stopCommand)
 {
     _softPhone = softPhone;
     _isIncoming = isIncoming;
     _acceptCommand = acceptCommand;
     _rejectCommand = rejectCommand;
     _stopCommand = stopCommand;
 }
 protected SoftPhoneSpecificationBase()
 {
     _testClientUaUri = TestConstants.EndPoint1Uri;
     _testClientUaEndPoint = TestConstants.IpEndPoint1;
     _phoneUaUri = TestConstants.EndPoint2Uri;
     _phoneUaEndPoint = TestConstants.IpEndPoint2;
     _timerFactory = new TimerFactoryStubBuilder().Build();
     _stateProvider = CreateStateProviderMock();
 }
예제 #7
0
        public void SipUri_Clone()
        {
            SipUri uri, clone;

            uri   = new SipUri("sip:[email protected]:1234;p1=one;p2=two?h1=header1&h2=header2");
            clone = uri.Clone();
            Assert.AreEqual(uri.ToString(), clone.ToString());
            Assert.AreEqual(uri.IsSecure, clone.IsSecure);
            Assert.AreEqual(uri.User, clone.User);
            Assert.AreEqual(uri.Host, clone.Host);
            Assert.AreEqual(uri.Port, clone.Port);
        }
예제 #8
0
        public void SipWatsonIpv6EmptyContactPasswordPortParameterTest(string sipUirText)
        {
            var testee = new SipUri(sipUirText);

            Assert.Empty(testee.Contact);
            Assert.Equal("watson", testee.UserName);
            Assert.Equal("password", testee.Password);
            Assert.Equal("[::ffff:192.0.2.2]", testee.Domain);
            Assert.Equal(5060, testee.Port);
            Assert.Equal("param", testee.UriParameters.Single().Name);
            Assert.Equal("value", testee.UriParameters.Single().Value);
        }
예제 #9
0
        public void SipWatsonContactPasswordPortParameterTest(string sipUirText)
        {
            var testee = new SipUri(sipUirText);

            Assert.Equal("Test a contact", testee.Contact);
            Assert.Equal("watson", testee.UserName);
            Assert.Equal("password", testee.Password);
            Assert.Equal("bell-telephone.com", testee.Domain);
            Assert.Equal(5060, testee.Port);
            Assert.Equal("param", testee.UriParameters.Single().Name);
            Assert.Equal("value", testee.UriParameters.Single().Value);
        }
예제 #10
0
        //[InlineData("sip:[email protected]\r\n;\r\nparam=value")]
        //[InlineData("<sip:[email protected]>\r\n;\r\nparam\r\n=\r\nvalue")]
        public void SipWatsonParameterTest(string sipUirText)
        {
            var testee = new SipUri(sipUirText);

            Assert.Empty(testee.Contact);
            Assert.Equal("watson", testee.UserName);
            Assert.Null(testee.Password);
            Assert.Equal("bell-telephone.com", testee.Domain);
            Assert.Single(testee.UriParameters);
            Assert.Equal("param", testee.UriParameters.Single().Name);
            Assert.Equal("value", testee.UriParameters.Single().Value);
        }
예제 #11
0
        public RegistrationContact Find(SipUri uri)
        {
            foreach (RegistrationContact contact in Contacts)
            {
                if (contact.Uri == uri)
                {
                    return(contact);
                }
            }

            return(null);
        }
예제 #12
0
        // very dirty
        public static String GetValidPhoneNumber(String uri)
        {
            if (uri != null && (uri.StartsWith("sip:") || uri.StartsWith("sip:") || uri.StartsWith("tel:")))
            {
                SipUri sipUri = new SipUri(uri);
                if (sipUri.isValid())
                {
                    String userName = sipUri.getUserName();
                    if (userName != null)
                    {
                        try
                        {
                            String scheme = sipUri.getScheme();
                            if (scheme != null && scheme.Equals("tel"))
                            {
                                userName = userName.Replace("-", "");
                            }

                            long result = Convert.ToInt64(userName.StartsWith("+") ? userName.Substring(1) : userName);
                            if (result < UriUtils.MAX_PHONE_NUMBER)
                            {
                                return(userName);
                            }
                        }
                        catch (FormatException) { }
                        catch (Exception e)
                        {
                            LOG.Error(e);
                        }
                    }
                }
                sipUri.Dispose();
            }
            else
            {
                try
                {
                    uri = uri.Replace("-", "");
                    long result = Convert.ToInt64(uri.StartsWith("+") ? uri.Substring(1) : uri);
                    if (result < UriUtils.MAX_PHONE_NUMBER)
                    {
                        return(uri);
                    }
                }
                catch (FormatException) { }
                catch (Exception e)
                {
                    LOG.Error(e);
                }
            }
            return(null);
        }
예제 #13
0
        public void SipUri_Cast()
        {
            SipUri uri;

            Assert.IsNull((SipUri)(string)null);
            Assert.IsNull((string)(SipUri)null);

            uri = new SipUri(SipTransportType.TCP, new NetworkBinding("lilltek.com", 55));
            Assert.AreEqual("sip:lilltek.com:55;transport=tcp", (string)uri);

            uri = (SipUri)"sip:lilltek.com:55;transport=tcp";
            Assert.AreEqual("sip:lilltek.com:55;transport=tcp", uri.ToString());
        }
예제 #14
0
        public void should_handle_displayname_without_schema()
        {
            var sipUri = "Anders Stenberg <[email protected]:5060;user=phone;transport=udp>";
            var parser = new SipUri(sipUri);

            Assert.AreEqual("Anders Stenberg", parser.DisplayName);
            Assert.AreEqual("", parser.Schema);
            Assert.AreEqual("andste", parser.User);
            Assert.AreEqual("acip.example.com", parser.Host);
            Assert.AreEqual("*****@*****.**", parser.UserAtHost);
            Assert.AreEqual("5060", parser.Port);
            Assert.AreEqual("user=phone;transport=udp", parser.Parameters);
        }
예제 #15
0
 public void Shall_parse_uri()
 {
     Assert.That(SipUri.TryParse("sip:admin:[email protected]:1234;param=foo?header=bar", out SipUri uri), Is.True);
     Assert.That(uri.Scheme, Is.EqualTo("sip"));
     Assert.That(uri.Host, Is.EqualTo("1.2.3.4"));
     Assert.That(uri.Port, Is.EqualTo("1234"));
     Assert.That(uri.Username, Is.EqualTo("admin"));
     Assert.That(uri.Password, Is.EqualTo("pwd"));
     Assert.That(uri.Parameters.Single().Name, Is.EqualTo("param"));
     Assert.That(uri.Parameters.Single().Value, Is.EqualTo("foo"));
     Assert.That(uri.Headers.Single().Name, Is.EqualTo("header"));
     Assert.That(uri.Headers.Single().Value, Is.EqualTo("bar"));
 }
예제 #16
0
        public static Contact FindContactByUri(SipUri uri)
        {
            Contact contact = null;

            foreach (Contact c in RobotCore.Host.Contacts)
            {
                if (c.Uri.Raw == uri.Raw)
                {
                    contact = c;
                    break;
                }
            }
            return(contact);
        }
예제 #17
0
        public void SipContactValue_Uri()
        {
            SipContactValue v;
            SipUri          uri;

            v = new SipContactValue("sip:[email protected]");
            Assert.AreEqual("sip:[email protected]", v.Uri);
            Assert.IsNull(v.DisplayName);
            Assert.AreEqual("<sip:[email protected]>", v.ToString());

            uri = new SipUri("sip:[email protected];transport=tcp");
            v   = uri;
            Assert.AreEqual("<sip:[email protected];transport=tcp>", v.ToString());
        }
예제 #18
0
 public Authenticate CreateWwwHeader(string realm, SipUri domain)
 {
     var header = new Authenticate(Authenticate.WWW_NAME)
                      {
                          Algortihm = "MD5",
                          Domain = domain,
                          Realm = realm,
                          Nonce = _nonce.Create(),
                          Opaque = Guid.NewGuid().ToString().Replace("-", string.Empty),
                          Qop = "auth",
                          Stale = false
                      };
     return header;
 }
예제 #19
0
        /// <summary>
        /// Start messaging
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="to"></param>
        /// <param name="callbackUrl"></param>
        /// <returns></returns>
        public Task <IMessagingInvitation> StartMessagingAsync(string subject, SipUri to, string callbackContext, LoggingContext loggingContext = null)
        {
            Logger.Instance.Information(string.Format("[Communication] calling startMessaging. LoggingContext: {0}",
                                                      loggingContext == null ? string.Empty : loggingContext.ToString()));

            string href = PlatformResource?.StartMessagingLink?.Href;

            if (string.IsNullOrWhiteSpace(href))
            {
                throw new CapabilityNotAvailableException("Link to start messaging is not available.");
            }

            return(StartMessagingWithIdentityAsync(subject, to.ToString(), callbackContext, null, href, null, null, loggingContext));
        }
예제 #20
0
        /// <exception cref="InvalidOperationException"><c>InvalidOperationException</c>.</exception>
        private static void Test(string uriString)
        {
            var reader = new StringReader();

            reader.Assign(uriString);

            SipUri uri = Parse(reader);

            if (uri == null)
            {
                throw new InvalidOperationException("Failed to parse: " + uriString);
            }

            Assert.Equal(uriString, uri.ToString());
        }
예제 #21
0
        public async Task <ActionResult <bool> > Hangup([FromBody] HangupRequest request)
        {
            if (request == null)
            {
                return(BadRequest());
            }

            log.Info($"Request to Hangup. SipAddress={request.SipAddress} DeviceEncoder={request.DeviceEncoder}");

            string hangUpWithDeviceEncoder = string.IsNullOrEmpty(request.DeviceEncoder) ? "Program" : request.DeviceEncoder;

            var caller = new SipUri(request.SipAddress).UserAtHost;

            return(await Execute(caller, async (codecApi, codecInformation) => await codecApi.HangUpAsync(codecInformation.Ip, hangUpWithDeviceEncoder)));
        }
예제 #22
0
        public Authenticate CreateWwwHeader(string realm, SipUri domain)
        {
            var header = new Authenticate(Authenticate.WWW_NAME)
            {
                Algortihm = "MD5",
                Domain    = domain,
                Realm     = realm,
                Nonce     = _nonce.Create(),
                Opaque    = Guid.NewGuid().ToString().Replace("-", string.Empty),
                Qop       = "auth",
                Stale     = false
            };

            return(header);
        }
예제 #23
0
        public static string GetUserName(string uri)
        {
            string userName = null;

            if (!string.IsNullOrEmpty(uri))
            {
                SipUri sipUri = new SipUri(uri);
                if (sipUri.isValid())
                {
                    userName = sipUri.getUserName();
                }
                sipUri.Dispose();
            }
            return((userName == null) ? uri : userName);
        }
예제 #24
0
        public void Shall_stringify_header()
        {
            var header = new NameAddressHeader
            {
                DisplayName = "Mr President",
                Url         = SipUri.Parse("sip:[email protected]"),
                Parameters  =
                {
                    new GenericParameter("foo", "bar")
                }
            };

            Assert.That(
                header.ToString(),
                Is.EqualTo("Mr President <sip:[email protected]>;foo=bar"));
        }
예제 #25
0
        /// <summary>
        ///     Initialize new sip dialogue.
        /// </summary>
        /// <param name="initRequestMethod"></param>
        /// <param name="requestUri"></param>
        /// <param name="from"></param>
        /// <param name="transactionLayer"></param>
        public SipDialogue(string initRequestMethod, SipUri requestUri, Identification from, ISipTransactionLayer transactionLayer)
            : this()
        {
            From           = from;
            To             = new Identification(from.Uri, null);
            DestinationUri = requestUri;

            _transactionLayer = transactionLayer;
            _transactionLayer.TransactionComplete += PrivateTransactionAgent_TransactionComplete;

            DialogueId       = DialogueHelpers.GenerateCallId();
            _responseHandler = new DefaultResponseHandler();
            _initRequest     = initRequestMethod; // Temporary solution, must be handled by "dialogue flow"

            // TODO create default action with init request method
        }
예제 #26
0
        public async void TestSetup()
        {
            m_restfulClient = new MockRestfulClient();
            Logger.RegisterLogger(new ConsoleLogger());
            m_loggingContext = new LoggingContext(Guid.NewGuid());
            TestHelper.InitializeTokenMapper();

            Uri    discoverUri           = TestHelper.DiscoverUri;
            Uri    baseUri               = UriHelper.GetBaseUriFromAbsoluteUri(discoverUri.ToString());
            SipUri ApplicationEndpointId = TestHelper.ApplicationEndpointUri;

            var discover = new Discover(m_restfulClient, baseUri, discoverUri, this);
            await discover.RefreshAndInitializeAsync(ApplicationEndpointId.ToString(), m_loggingContext).ConfigureAwait(false);

            m_application = discover.Application;
        }
예제 #27
0
        /// <summary>
        /// add participant as an asynchronous operation.
        /// </summary>
        /// <param name="targetSip">The target sip.</param>
        /// <param name="loggingContext">The logging context.</param>
        /// <returns>Task&lt;IParticipantInvitation&gt;.</returns>
        /// <exception cref="CapabilityNotAvailableException">Link to add participant is not available.</exception>
        /// <exception cref="RemotePlatformServiceException">
        /// Timeout to get Participant invitation started event from platformservice!
        /// or
        /// Platformservice do not deliver a ParticipantInvitation resource with operationId " + operationId
        /// </exception>
        public async Task <IParticipantInvitation> AddParticipantAsync(SipUri targetSip, LoggingContext loggingContext = null)

        {
            string href = PlatformResource?.AddParticipantResourceLink?.Href;

            if (string.IsNullOrEmpty(href))
            {
                throw new CapabilityNotAvailableException("Link to add participant is not available.");
            }

            var communication = this.Parent as Communication;

            IInvitation invite      = null;
            string      operationId = Guid.NewGuid().ToString();
            TaskCompletionSource <IInvitation> tcs = new TaskCompletionSource <IInvitation>();

            communication.HandleNewInviteOperationKickedOff(operationId, tcs);

            var input = new AddParticipantInvitationInput
            {
                OperationContext = operationId,
                To = targetSip.ToString()
            };

            Uri addparticipantUrl = UriHelper.CreateAbsoluteUri(this.BaseUri, href);

            await this.PostRelatedPlatformResourceAsync(addparticipantUrl, input, new ResourceJsonMediaTypeFormatter(), loggingContext).ConfigureAwait(false);

            try
            {
                invite = await tcs.Task.TimeoutAfterAsync(WaitForEvents).ConfigureAwait(false);
            }
            catch (TimeoutException)
            {
                throw new RemotePlatformServiceException("Timeout to get Participant invitation started event from platformservice!");
            }

            var result = invite as ParticipantInvitation;

            if (result == null)
            {
                throw new RemotePlatformServiceException("Platformservice do not deliver a ParticipantInvitation resource with operationId " + operationId);
            }

            return(result);
        }
예제 #28
0
        public void SipUri_Parameters()
        {
            SipUri uri;

            uri = new SipUri("sip:[email protected];one=two;three=four");
            Assert.AreEqual("sip:[email protected];one=two;three=four", uri.ToString());
            Assert.AreEqual("jeff", uri.User);
            Assert.AreEqual("lilltek.com", uri.Host);
            Assert.AreEqual(NetworkPort.SIP, uri.Port);
            Assert.AreEqual("two", uri.Parameters["ONE"]);
            Assert.AreEqual("four", uri.Parameters["three"]);

            uri = new SipUri("sip:[email protected]:1234;one=two;three=four");
            Assert.AreEqual("sip:[email protected]:1234;one=two;three=four", uri.ToString());
            Assert.AreEqual("jeff", uri.User);
            Assert.AreEqual("lilltek.com", uri.Host);
            Assert.AreEqual(1234, uri.Port);
            Assert.AreEqual("two", uri.Parameters["ONE"]);
            Assert.AreEqual("four", uri.Parameters["three"]);

            uri = new SipUri("sip:lilltek.com;one=two;three=four");
            Assert.IsFalse(uri.IsSecure);
            Assert.IsNull(uri.User);
            Assert.AreEqual("lilltek.com", uri.Host);
            Assert.AreEqual("lilltek.com", uri.Host);
            Assert.AreEqual(NetworkPort.SIP, uri.Port);
            Assert.AreEqual("sip:lilltek.com;one=two;three=four", uri.ToString());

            uri = new SipUri("sip:lilltek.com:1234;one=two;three=four");
            Assert.IsFalse(uri.IsSecure);
            Assert.IsNull(uri.User);
            Assert.AreEqual("lilltek.com", uri.Host);
            Assert.AreEqual("lilltek.com", uri.Host);
            Assert.AreEqual(1234, uri.Port);
            Assert.AreEqual("sip:lilltek.com:1234;one=two;three=four", uri.ToString());

            uri = new SipUri("sip:lilltek.com:1234;one=two;three=four");
            Assert.IsNull(uri["five"]);
            uri["five"] = "six";
            Assert.AreEqual("six", uri["five"]);
            Assert.AreEqual("two", uri["one"]);
            uri["one"] = "xxx";
            Assert.AreEqual("xxx", uri["one"]);
            uri["three"] = null;
            Assert.IsFalse(uri.Parameters.ContainsKey("three"));
        }
예제 #29
0
        private void TestRequestLine()
        {
            SipUri uri = UriParser.Parse("sips:127.0.0.1:5061");

            Assert.Equal(5061, uri.Port);
            Assert.Equal("sips", uri.Scheme);
            Assert.Equal("127.0.0.1", uri.Domain);

            uri = UriParser.Parse("127.0.0.1:5061");
            Assert.Equal(5061, uri.Port);
            Assert.Equal(string.Empty, uri.Scheme);
            Assert.Equal("127.0.0.1", uri.Domain);

            uri = UriParser.Parse("sips:127.0.0.1");
            Assert.Equal(0, uri.Port);
            Assert.Equal("sips", uri.Scheme);
            Assert.Equal("127.0.0.1", uri.Domain);
        }
예제 #30
0
        /// <summary>
        /// SMS packet.
        /// </summary>
        /// <param name="sipUri">The sipURI.</param>
        /// <param name="msgContent">Content of the Msg.</param>
        /// <param name="isCatMsg">是否是长短信</param>
        /// <returns></returns>
        public static SipMessage SMSPacket(SipUri sipUri, string msgContent, bool isCatMsg)
        {
            string eventName = (isCatMsg == true ? "SendCatSMS" : "SendSMS");

            SipRequest   req     = new SipRequest(SipMethodName.Message, DEFAULT_URI);
            SipHeadField hFrom   = new SipHeadField(SipHeadFieldName.From, Ower.Uri.Sid.ToString());
            SipHeadField hCallID = new SipHeadField(SipHeadFieldName.CallID, Ower.Conncetion.NextCallID().ToString());
            SipHeadField hCSeq   = new SipHeadField(SipHeadFieldName.CSeq, "1 " + SipMethodName.Message);
            SipHeadField hTo     = new SipHeadField(SipHeadFieldName.To, sipUri.ToString());
            SipHeadField hEvent  = new SipHeadField(SipHeadFieldName.Event, eventName);

            req.HeadFields.Add(hFrom);
            req.HeadFields.Add(hCallID);
            req.HeadFields.Add(hCSeq);
            req.HeadFields.Add(hTo);
            req.HeadFields.Add(hEvent);
            req.Body = msgContent;
            return(req);
        }
예제 #31
0
        public void Shall_calculate_content_length()
        {
            var request = new SipRequest
            {
                Method     = "INVITE",
                RequestUri = SipUri.Parse("sip:[email protected]")
            };

            request.Bodies.Add(new SipBody
            {
                Data = "Senior Trump"
            });

            Assert.That(request.ContentLength.Value, Is.EqualTo("12"));

            request.Bodies.Clear();

            Assert.That(request.ContentLength.Value, Is.EqualTo("0"));
        }
예제 #32
0
        public static SipMessage LeaveMsgPacket(SipUri sipUri, string msgContent)
        {
            SipRequest   req          = new SipRequest(SipMethodName.Message, DEFAULT_URI);
            SipHeadField hFrom        = new SipHeadField(SipHeadFieldName.From, Ower.Uri.Sid.ToString());
            SipHeadField hCallID      = new SipHeadField(SipHeadFieldName.CallID, Ower.Conncetion.NextCallID().ToString());
            SipHeadField hCSeq        = new SipHeadField(SipHeadFieldName.CSeq, "2 M");
            SipHeadField hTo          = new SipHeadField(SipHeadFieldName.To, sipUri.ToString());
            SipHeadField hContentType = new SipHeadField(SipHeadFieldName.ContentType, "text/plain");
            SipHeadField hSupported   = new SipHeadField(SipHeadFieldName.Supported, "SaveHistory");

            req.HeadFields.Add(hFrom);
            req.HeadFields.Add(hCallID);
            req.HeadFields.Add(hCSeq);
            req.HeadFields.Add(hTo);
            req.HeadFields.Add(hContentType);
            req.HeadFields.Add(hSupported);
            req.Body = msgContent;
            return(req);
        }
예제 #33
0
        public SipUri CreateUri(string user, string hostOrDomain)
        {
            Check.NotNullOrEmpty(hostOrDomain, "hostOrDomain");

            var splitted = hostOrDomain.Split(':').ToList();

            Check.IsTrue(splitted.Count, x=> x <= 2, "hostOrDomain has invalid format");

            int port = -1;
            if (splitted.Count == 2)
            {
                Check.IsTrue(splitted[1], x => int.TryParse(x, out port), "hostOrDomain has invalid format");
            }

            var uri = new SipUri() {User = user, Host = splitted[0]};
            if (port > -1) uri.Port = port;

            return uri;
        }
예제 #34
0
        public static SipMessage AddBuddy(SipUri buddyUri, string desc)
        {
            if (string.IsNullOrEmpty(desc))
            {
                desc = Ower.NickName;
            }
            string       msgContent = string.Format("<args><contacts><buddies><buddy uri=\"{0}\" buddy-lists=\"\" desc=\"{1}\" expose-mobile-no=\"1\" expose-name=\"1\" addbuddy-phrase-id=\"0\" /></buddies></contacts></args>", buddyUri.ToString(), desc);
            SipRequest   req        = new SipRequest(SipMethodName.Service, DEFAULT_URI);
            SipHeadField hFrom      = new SipHeadField(SipHeadFieldName.From, Ower.Uri.Sid.ToString());
            SipHeadField hCallID    = new SipHeadField(SipHeadFieldName.CallID, Ower.Conncetion.NextCallID().ToString());
            SipHeadField hCSeq      = new SipHeadField(SipHeadFieldName.CSeq, "1 " + SipMethodName.Service);
            SipHeadField hEvent     = new SipHeadField(SipHeadFieldName.Event, "AddBuddyV4");

            req.HeadFields.Add(hFrom);
            req.HeadFields.Add(hCallID);
            req.HeadFields.Add(hCSeq);
            req.HeadFields.Add(hEvent);
            req.Body = msgContent;
            return(req);
        }
예제 #35
0
        /// <summary>
        /// Accept the incoming call and set up b2b call with conference or target user
        /// </summary>
        /// <param name="loggingContext"></param>
        /// <param name="meetingUri">the onlinemeeting uri if you want to bridge to a conference</param>
        /// <param name="to">the sip uri if you want to bridge to a single person</param>
        /// <returns></returns>
        private Task AcceptAndBridgeAsync(string meetingUri, SipUri to, LoggingContext loggingContext = null)
        {
            Logger.Instance.Information(string.Format("[AudioVideoInviation] calling AcceptAndBridgeAsync. LoggingContext:{0}", loggingContext == null ? string.Empty : loggingContext.ToString()));

            string href = PlatformResource?.AcceptAndBridgeAudioVideoLink?.Href;

            if (string.IsNullOrWhiteSpace(href))
            {
                throw new CapabilityNotAvailableException("Link to accept and bridge is not available.");
            }

            var input = new AcceptAndBridgeAudioVideoInput
            {
                MeetingUri = meetingUri,
                ToUri      = to.ToString()
            };

            Uri bridge = UriHelper.CreateAbsoluteUri(this.BaseUri, href);

            return(this.PostRelatedPlatformResourceAsync(bridge, input, new ResourceJsonMediaTypeFormatter(), loggingContext));
        }
예제 #36
0
        protected SipRequest CreateInviteRequest(SipUri from, SipUri to)
        {
            var r = new SipRequestBuilder()
                    .WithRequestLine(
                new SipRequestLineBuilder().WithMethod(SipMethods.Invite).Build())
                    .WithCSeq(
                new SipCSeqHeaderBuilder().WithCommand(SipMethods.Invite).WithSequence(1).Build())
                    .WithFrom(
                new SipFromHeaderBuilder().WithSipUri(from).WithTag(SipUtil.CreateTag()).Build())
                    .WithTo(
                new SipToHeaderBuilder().WithSipUri(to).WithTag(null).Build())
                    .WithCallId(
                new SipCallIdHeaderBuilder().WithValue(SipUtil.CreateCallId()).Build())
                    .WithContacts(
                new SipContactHeaderListBuilder()
                .Add(new SipContactHeaderBuilder().WithSipUri(from).Build())
                .Build())
                    .Build();

            return(r);
        }
        protected SipRequest CreateInviteRequest(SipUri from, SipUri to)
        {
            var r = new SipRequestBuilder()
                .WithRequestLine(
                    new SipRequestLineBuilder().WithMethod(SipMethods.Invite).Build())
                .WithCSeq(
                    new SipCSeqHeaderBuilder().WithCommand(SipMethods.Invite).WithSequence(1).Build())
                .WithFrom(
                    new SipFromHeaderBuilder().WithSipUri(from).WithTag(SipUtil.CreateTag()).Build())
                .WithTo(
                    new SipToHeaderBuilder().WithSipUri(to).WithTag(null).Build())
                .WithCallId(
                    new SipCallIdHeaderBuilder().WithValue(SipUtil.CreateCallId()).Build())
                .WithContacts(
                    new SipContactHeaderListBuilder()
                        .Add(new SipContactHeaderBuilder().WithSipUri(from).Build())
                        .Build())
                .Build();

            return r;
        }
예제 #38
0
        public void Shall_stringify_header()
        {
            var uri = new SipUri
            {
                Host       = "1.2.3.4",
                Port       = "1234",
                Username   = "******",
                Password   = "******",
                Parameters =
                {
                    new SipUriParameter("param", "foo")
                },
                Headers =
                {
                    new SipUriParameter("header", "bar")
                }
            };

            Assert.That(
                uri.ToString(),
                Is.EqualTo("sip:admin:[email protected]:1234;param=foo?header=bar"));
        }
예제 #39
0
        private void AddBuddy()
        {
            if (analyzer == null)
            {
                return;
            }
            string regex      = @"(sip:\d+)|(tel:\d+)";
            bool   foundMatch = Regex.IsMatch(this.cmd.Para, regex, RegexOptions.Singleline | RegexOptions.IgnoreCase);

            if (foundMatch)
            {
                string sipurl = Regex.Match(this.cmd.Para, regex).Value;
                Client fetion = RobotCore.Fetion;
                SipUri uri    = new SipUri(sipurl);
                if (fetion != null)
                {
                    fetion.AddBuddy(uri, string.Empty);
                    string c = string.Format("向{0}的好友请求已发送", sipurl);
                    analyzer.Send(c);
                }
            }
        }
예제 #40
0
        public SipRequest CreateRequest(SipUri requestUri, string method, SipCallIdHeader callId, SipCSeqHeader cSeq, SipFromHeader from, SipToHeader to, SipViaHeader viaHeader, SipMaxForwardsHeader maxForwards)
        {
            Check.Require(requestUri, "requestUri");
             Check.Require(method, "method");
             Check.Require(callId, "callId");
             Check.Require(cSeq, "cseq");
             Check.Require(from, "from");
             Check.Require(to , "to");
             Check.Require( viaHeader,"viaHeader");
             Check.Require(maxForwards,  "maxforwards");

            var message = new SipRequest();
            message.RequestLine.Method = method;
            message.RequestLine.Uri = requestUri;
            message.RequestLine.Version = SipConstants.SipTwoZeroString;
            message.CallId = callId;
            message.To = to;
            message.From = from;
            message.CSeq = cSeq;
            message.Vias.SetTopMost(viaHeader);
            message.MaxForwards = maxForwards;
            return message;
        }
예제 #41
0
 internal static IPEndPoint ConvertToIpEndPoint(SipUri sipUri)
 {
     if(!IsIPAddress(sipUri.Host)) return null;
     return new IPEndPoint(IPAddress.Parse(sipUri.Host), sipUri.Port);
 }
예제 #42
0
        public void Start(string to)
        {
            Check.IsTrue(!_isIncoming, "Failed to start a call. Only outgoing calls can be started.");

            if (!to.StartsWith("sip:")) to = "sip:" + to;

            if (!SipUtil.IsSipUri(to)) throw new ArgumentException("'to' argument is has invalid format.");

            var uri = SipUtil.ParseSipUri(to);

            if (_softPhone.RegisteredPhoneLine == null)
            {
                if (uri.HasNamedHost()) throw new ArgumentException("'to' argument is not valid. Since phone is not registered, 'to' can not be a named host. Only numeric IP hosts are supported.");
                _toUri = uri;
            }
            else
            {
                _toUri = uri;
            }
            
            _startCommand.Execute(this);
        }
예제 #43
0
        private IPEndPoint GetDestinationEndPoint(SipUri uri)
        {
            if (SipUtil.IsIPAddress(uri.Host))
            {
                return new IPEndPoint(IPAddress.Parse(uri.Host), uri.Port);
            }

            throw new NotSupportedException(ExceptionMessage.NamedHostsAreNotSupported);
        }
예제 #44
0
        public RegistrationContact Find(SipUri uri)
        {
            foreach (RegistrationContact contact in Contacts)
            {
                if (contact.Uri == uri)
                    return contact;
            }

            return null;
        }
예제 #45
0
 /// <summary>
 /// Update uri used when registering.
 /// </summary>
 /// <param name="uri"></param>
 /// <remarks>
 /// User might use a different domain than the one
 /// added to the database. Update it so that we can find the user.
 /// </remarks>
 public void UpdateUri(Registration registration, SipUri uri)
 {
     if (uri.Equals(registration.Uri))
         return;
     _registrations.Add(uri.ToString(), registration);
     _registrations.Remove(registration.Uri.ToString());
     registration.Uri = uri;
 }
예제 #46
0
        public SipRecordRouteHeader CreateRecordRouteHeader(SipUri uri)
        {
            Check.Require(uri, "uri");

            return new SipRecordRouteHeader() { SipUri = uri};
        }
예제 #47
0
        public SipContactHeader CreateContactHeader(SipUri uri)
        {
            Check.Require(uri, "uri");

            return new SipContactHeader() { SipUri = uri };
        }
예제 #48
0
 /// <summary>
 /// Create a new registration object.
 /// </summary>
 /// <param name="uri"></param>
 /// <returns></returns>
 public Registration Create(SipUri uri)
 {
     return new Registration {Uri = uri};
 }
예제 #49
0
 /// <summary>
 /// Checks if a user exists.
 /// </summary>
 /// <param name="contact"></param>
 /// <param name="realm"></param>
 /// <returns></returns>
 public bool Exists(Contact contact, SipUri realm)
 {
     return _authenticationIndex.ContainsKey(contact.Uri.UserName + "@" + contact.Uri.Domain);
 }
예제 #50
0
 /// <summary>
 /// Get registration for a user.
 /// </summary>
 /// <param name="uri"></param>
 /// <returns></returns>
 public Registration Get(SipUri uri)
 {
     Registration registration;
     return _registrations.TryGetValue(uri.ToString(), out registration) ? registration : null;
 }
예제 #51
0
 public SipAddress CreateAddress(string displayInfo, SipUri uri)
 {
     return new SipAddress() { DisplayInfo = displayInfo, Uri = uri};
 }
예제 #52
0
 protected virtual bool IsOurDomain(SipUri uri)
 {
     return true;
 }
예제 #53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RouteEntry"/> class.
 /// </summary>
 /// <param name="headerName">Name of the header.</param>
 public RouteEntry(string headerName)
 {
     _name = headerName;
     Uri = new SipUri();
 }
예제 #54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Contact"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="uri">The URI.</param>
 public RegistrationContact(string name, SipUri uri)
     : base(name, uri)
 {
 }