protected SipResponse CreateRingingResponse() { var r = _inviteRequest.CreateResponse(SipResponseCodes.x180_Ringing); r.To.Tag = _toTag; _inviteRequest.Contacts.ToList().ForEach(r.Contacts.Add); return(r); }
private SipResponse CreateRingingResponse(SipRequest request) { var r = request.CreateResponse(SipResponseCodes.x180_Ringing); r.To.Tag = _toTag; return(r); }
protected SipResponse CreateResponse(SipRequest receivedInvite, string toTag, string responseCode) { var r = receivedInvite.CreateResponse(responseCode); r.To.Tag = toTag; var contactUri = _phone.AddressFactory.CreateUri("", _phoneUaEndPoint.ToString()); r.Contacts.Add(_phone.HeaderFactory.CreateContactHeader(contactUri)); return(r); }
private void OnRequest(object sender, SipRequestEventArgs args) { SipRequest request = args.Request; switch (request["Test"].Text) { case "OK": args.Response = request.CreateResponse(SipStatus.OK, null); break; case "Error": args.Response = request.CreateResponse(SipStatus.ServerError, null); break; default: args.Response = request.CreateResponse(SipStatus.NotImplemented, null); break; } }
private void SendRinging() { if (_ringingResponse == null) { _ringingResponse = _inviteRequest.CreateResponse(SipResponseCodes.x180_Ringing); _ringingResponse.To.Tag = SipUtil.CreateTag(); var contactUri = AddressFactory.CreateUri("", MainForm.SipProvider.ListeningPoint.ToString()); _ringingResponse.Contacts.Add(HeaderFactory.CreateContactHeader(contactUri)); _inviteTransaction = (SipInviteServerTransaction)SipProvider.CreateServerTransaction(_inviteRequest); _dialog = SipProvider.CreateServerDialog(_inviteTransaction); _inviteTransaction.SendResponse(_ringingResponse); } else { _inviteTransaction.SendResponse(_ringingResponse); } }
protected override void When() { Request = new SipRequestBuilder().Build(); _response = Request.CreateResponse(SipResponseCodes.x200_Ok); }
public void SipBasicCore_Request_SetResponse() { // Verify that we can submit a non-dialog request from // one core to another, respond to it by setting the // Response property of the RequestReceived handler arguments // and then actually receive the response. StartCores(); try { SipResponse core1Response = null; core1.ResponseReceived += delegate(object sender, SipResponseEventArgs args) { core1Response = args.Response; }; SipRequest core2Request = null; core2.RequestReceived += delegate(object sender, SipRequestEventArgs args) { core2Request = args.Request; args.Response = core2Request.CreateResponse(SipStatus.OK, "Hello World!"); args.Response.Contents = new byte[] { 5, 6, 7, 8 }; }; // Submit a request and verify the response. SipRequest request; SipResult result; SipResponse response; request = new SipRequest(SipMethod.Info, (string)core2Uri, null); request.Contents = new byte[] { 1, 2, 3, 4 }; result = core1.Request(request); response = result.Response; Assert.AreEqual(SipStatus.OK, result.Status); Assert.AreEqual(SipStatus.OK, response.Status); Assert.AreEqual("Hello World!", response.ReasonPhrase); CollectionAssert.AreEqual(new byte[] { 5, 6, 7, 8 }, response.Contents); // Verify that the core1 ResponseReceived event handler was called Assert.IsNotNull(core1Response); Assert.AreEqual(SipStatus.OK, core1Response.Status); Assert.AreEqual("Hello World!", core1Response.ReasonPhrase); CollectionAssert.AreEqual(new byte[] { 5, 6, 7, 8 }, core1Response.Contents); // Verify that the core2 RequestReceived event handler was called Assert.IsNotNull(core2Request); Assert.AreEqual(SipMethod.Info, core2Request.Method); CollectionAssert.AreEqual(new byte[] { 1, 2, 3, 4 }, core2Request.Contents); } finally { StopCores(); } }
public void SipBasicCore_Outbound_Proxy() { // Verify that we can we can force a request to a destination // other than that specified in the request URI by specifying // the core's OutboundProxyUri. StartCores(); try { SipResponse core1Response = null; core1.ResponseReceived += delegate(object sender, SipResponseEventArgs args) { core1Response = args.Response; }; SipRequest core2Request = null; core2.RequestReceived += delegate(object sender, SipRequestEventArgs args) { SipResponse reply; core2Request = args.Request; reply = core2Request.CreateResponse(SipStatus.OK, "Hello World!"); reply.Contents = new byte[] { 5, 6, 7, 8 }; core2.Reply(args, reply); }; // Submit a request and verify the response. SipRequest request; SipResult result; SipResponse response; core1.OutboundProxyUri = core2Uri; request = new SipRequest(SipMethod.Info, "sip:www.lilltek.com:8080;transport=tcp", null); request.Contents = new byte[] { 1, 2, 3, 4 }; result = core1.Request(request); response = result.Response; Assert.AreEqual(SipStatus.OK, result.Status); Assert.AreEqual(SipStatus.OK, response.Status); Assert.AreEqual("Hello World!", response.ReasonPhrase); CollectionAssert.AreEqual(new byte[] { 5, 6, 7, 8 }, response.Contents); // Verify that the core1 ResponseReceived event handler was called Assert.IsNotNull(core1Response); Assert.AreEqual(SipStatus.OK, core1Response.Status); Assert.AreEqual("Hello World!", core1Response.ReasonPhrase); CollectionAssert.AreEqual(new byte[] { 5, 6, 7, 8 }, core1Response.Contents); // Verify that the core2 RequestReceived event handler was called Assert.IsNotNull(core2Request); Assert.AreEqual(SipMethod.Info, core2Request.Method); CollectionAssert.AreEqual(new byte[] { 1, 2, 3, 4 }, core2Request.Contents); } finally { StopCores(); } }
public void SipBasicCore_Request_Blast() { // Verify that we can submit multiple requests to a core. StartCores(); try { SipResponse core1Response = null; core1.ResponseReceived += delegate(object sender, SipResponseEventArgs args) { core1Response = args.Response; }; SipRequest core2Request = null; core2.RequestReceived += delegate(object sender, SipRequestEventArgs args) { core2Request = args.Request; args.Response = core2Request.CreateResponse(SipStatus.OK, "Hello World!"); args.Response.Contents = args.Request.Contents; }; // Submit a bunch of request and verify the responses. for (int i = 0; i < 1000; i++) { SipRequest request; SipResult result; SipResponse response; byte[] data; data = new byte[4]; Helper.Fill32(data, i); request = new SipRequest(SipMethod.Info, (string)core2Uri, null); request.Contents = data; result = core1.Request(request); response = result.Response; Assert.AreEqual(SipStatus.OK, result.Status); Assert.AreEqual(SipStatus.OK, response.Status); Assert.AreEqual("Hello World!", response.ReasonPhrase); CollectionAssert.AreEqual(data, response.Contents); // Verify that the core1 ResponseReceived event handler was called Assert.IsNotNull(core1Response); Assert.AreEqual(SipStatus.OK, core1Response.Status); Assert.AreEqual("Hello World!", core1Response.ReasonPhrase); CollectionAssert.AreEqual(data, core1Response.Contents); // Verify that the core2 RequestReceived event handler was called Assert.IsNotNull(core2Request); Assert.AreEqual(SipMethod.Info, core2Request.Method); CollectionAssert.AreEqual(data, core2Request.Contents); } } finally { StopCores(); } }
public void SipBasicCore_Request_ReplyAsync() { // Verify that we can submit a non-dialog request from // one core to another, respond to it asynchronously and // then verify that we actually received the response. StartCores(); try { SipResponse core1Response = null; core1.ResponseReceived += delegate(object sender, SipResponseEventArgs args) { core1Response = args.Response; }; SipRequest core2Request = null; core2.RequestReceived += delegate(object sender, SipRequestEventArgs args) { SipResponse reply; core2Request = args.Request; reply = core2Request.CreateResponse(SipStatus.OK, "Hello World!"); reply.Contents = new byte[] { 5, 6, 7, 8 }; args.WillRespondAsynchronously = true; AsyncCallback callback = delegate(IAsyncResult ar) { AsyncTimer.EndTimer(ar); args.Transaction.SendResponse(reply); }; AsyncTimer.BeginTimer(TimeSpan.FromMilliseconds(100), callback, null); }; // Submit a request and verify the response. SipRequest request; SipResult result; SipResponse response; request = new SipRequest(SipMethod.Info, (string)core2Uri, null); request.Contents = new byte[] { 1, 2, 3, 4 }; result = core1.Request(request); response = result.Response; Assert.AreEqual(SipStatus.OK, result.Status); Assert.AreEqual(SipStatus.OK, response.Status); Assert.AreEqual("Hello World!", response.ReasonPhrase); CollectionAssert.AreEqual(new byte[] { 5, 6, 7, 8 }, response.Contents); // Verify that the core1 ResponseReceived event handler was called Assert.IsNotNull(core1Response); Assert.AreEqual(SipStatus.OK, core1Response.Status); Assert.AreEqual("Hello World!", core1Response.ReasonPhrase); CollectionAssert.AreEqual(new byte[] { 5, 6, 7, 8 }, core1Response.Contents); // Verify that the core2 RequestReceived event handler was called Assert.IsNotNull(core2Request); Assert.AreEqual(SipMethod.Info, core2Request.Method); CollectionAssert.AreEqual(new byte[] { 1, 2, 3, 4 }, core2Request.Contents); } finally { StopCores(); } }
private SipResponse CreateRingingResponse(SipRequest request) { var r = request.CreateResponse(SipResponseCodes.x180_Ringing); r.To.Tag = _toTag; return r; }
/// <summary> /// creates a ringing. this is to be sent by the testclient UA /// </summary> protected SipResponse CreateRingingResponse(SipRequest receivedInvite, string toTag) { var ringing = receivedInvite.CreateResponse(SipResponseCodes.x180_Ringing); ringing.To.Tag = toTag; var contactUri = _phone.AddressFactory.CreateUri("", _phoneUaEndPoint.ToString()); ringing.Contacts.Add(_phone.HeaderFactory.CreateContactHeader(contactUri)); return ringing; }
protected SipResponse CreateResponse(SipRequest receivedInvite, string toTag, string responseCode) { var r = receivedInvite.CreateResponse(responseCode); r.To.Tag = toTag; var contactUri = _phone.AddressFactory.CreateUri("", _phoneUaEndPoint.ToString()); r.Contacts.Add(_phone.HeaderFactory.CreateContactHeader(contactUri)); return r; }
public SipResponse CreateResponse(SipRequest request, string responseCode) { return request.CreateResponse(responseCode); }