private void SendResponse() { _response = new Response("SIP/2.0", StatusCode.OK, "OK!") { From = new Contact("Adam Nilsson", new SipUri("sip", "adam", "nilsson.com", 5060)), To = new Contact("Jonas Gauffin", new SipUri("jonas", "gauffin.com")), CallId = Guid.NewGuid().ToString().Replace("-", string.Empty), }; _response.CSeq = new CSeq(1, "INVITE"); //_response.Contact = _request.To; var listener = new TcpListener(IPAddress.Loopback, 12721); listener.Start(); listener.BeginAcceptSocket(OnNewSocket, listener); byte[] buffer = _bufferPool.Dequeue(); var serializer = new MessageSerializer(); int length = serializer.Serialize(_response, buffer); _transport.Send(new IPEndPoint(IPAddress.Loopback, 12721), buffer, 0, length); Assert.True(_manualEvent.WaitOne(1000)); }
private void ReceiveRequest() { var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(IPAddress.Loopback, 1324); _request = new Request("INVITE", "sips:[email protected]", "SIP/2.0") { From = new Contact("Adam Nilsson", new SipUri("sip", "adam", "nilsson.com", 5060)), To = new Contact("Jonas Gauffin", new SipUri("jonas", "gauffin.com")), CallId = Guid.NewGuid().ToString().Replace("-", string.Empty), CSeq = new CSeq(1, _request.Method), MaxForwards = 60 }; _request.Contact = _request.To; byte[] buffer = _bufferPool.Dequeue(); var serializer = new MessageSerializer(); int length = serializer.Serialize(_request, buffer); socket.Send(buffer, 0, length, SocketFlags.None); Assert.True(_manualEvent.WaitOne(1000)); }
private void SendResponse() { _response = new Response("SIP/2.0", StatusCode.OK, "OK!") { From = new Contact("Adam Nilsson", new SipUri("sip", "adam", "nilsson.com", 5060)), To = new Contact("Jonas Gauffin", new SipUri("jonas", "gauffin.com")), CallId = Guid.NewGuid().ToString().Replace("-", string.Empty), }; _response.CSeq = new CSeq(1, "INVITE"); //_response.Contact = _request.To; IAsyncResult res = CreateListener(); byte[] buffer = _bufferPool.Dequeue(); var serializer = new MessageSerializer(); int length = serializer.Serialize(_response, buffer); _transport.Send(new IPEndPoint(IPAddress.Loopback, 12721), buffer, 0, length); EndPoint ep = new IPEndPoint(IPAddress.Any, 1234); int bytesRead = _testSocket.EndReceiveFrom(res, ref ep); Assert.NotEqual(0, bytesRead); }