Search in sources :

Example 66 with Response

use of javax.sip.message.Response in project load-balancer by RestComm.

the class Shootist method processBye.

public void processBye(Request request, ServerTransaction serverTransactionId) {
    try {
        System.out.println("shootist:  got a bye .");
        if (serverTransactionId == null) {
            System.out.println("shootist:  null TID.");
            return;
        }
        Dialog dialog = serverTransactionId.getDialog();
        System.out.println("Dialog State = " + dialog.getState());
        Response response = messageFactory.createResponse(200, request);
        serverTransactionId.sendResponse(response);
        System.out.println("shootist:  Sending OK.");
        System.out.println("Dialog State = " + dialog.getState());
    } catch (Exception ex) {
        fail("Unexpected exception");
    }
}
Also used : Response(javax.sip.message.Response) Dialog(javax.sip.Dialog) TransactionAlreadyExistsException(javax.sip.TransactionAlreadyExistsException) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) PeerUnavailableException(javax.sip.PeerUnavailableException) SipException(javax.sip.SipException) TransactionUnavailableException(javax.sip.TransactionUnavailableException)

Example 67 with Response

use of javax.sip.message.Response in project load-balancer by RestComm.

the class SinglePointTest method testTcpToTcp.

@Test
public void testTcpToTcp() throws Exception {
    setUp(true);
    boolean wasRinging = false;
    boolean wasOk = false;
    shootistTcp.sendInitialInvite();
    Thread.sleep(5000);
    shootistTcp.sendBye();
    Thread.sleep(5000);
    assertTrue(server.getTestSipListener().isInviteReceived());
    assertTrue(server.getTestSipListener().isAckReceived());
    assertTrue(server.getTestSipListener().getByeReceived());
    for (Response res : shootistTcp.responses) {
        if (res.getStatusCode() == Response.RINGING)
            wasRinging = true;
        if (res.getStatusCode() == Response.OK)
            wasOk = true;
    }
    assertTrue(wasOk);
    assertTrue(wasRinging);
}
Also used : Response(javax.sip.message.Response) Test(org.junit.Test)

Example 68 with Response

use of javax.sip.message.Response in project load-balancer by RestComm.

the class NodeGracefulShutdownRmiTest method testGracefulRemovingNode.

@Test
public void testGracefulRemovingNode() throws Exception {
    int okNumber1 = 0;
    int okNumber2 = 0;
    shootist1.sendInitialInvite();
    Thread.sleep(500);
    for (AppServer server : servers) if (server.sipListener.getInviteRequest() != null)
        server.gracefulShutdown();
    Thread.sleep(5000);
    shootist1.sendBye();
    Thread.sleep(2000);
    shootist2.sendInitialInvite();
    Thread.sleep(5000);
    shootist2.sendBye();
    Thread.sleep(2000);
    for (Response res : shootist1.responses) if (res.getStatusCode() == Response.OK)
        okNumber1++;
    for (Response res : shootist2.responses) if (res.getStatusCode() == Response.OK)
        okNumber2++;
    for (AppServer server : servers) assertNotNull(server.sipListener.getInviteRequest());
    assertEquals(2, okNumber1);
    assertEquals(2, okNumber2);
}
Also used : AppServer(org.mobicents.tools.sip.balancer.AppServer) Response(javax.sip.message.Response) ListeningPoint(javax.sip.ListeningPoint) Test(org.junit.Test)

Example 69 with Response

use of javax.sip.message.Response in project load-balancer by RestComm.

the class FromURIBasedAlgorithmTest method testInviteFromToDifferentNodes.

@Test
public void testInviteFromToDifferentNodes() throws Exception {
    balancer.balancerContext.sipHeaderAffinityKeyExclusionPattern = Pattern.compile(".*sip.nexmo.com");
    for (int i = 0; i < shootists.length; i++) {
        String fromUri = "Anonymous";
        // if(i % 2 == 0) {
        // fromUri = "Restricted";
        // }
        shootists[i].sendInitial(fromUri, "sip.nexmo.com", "INVITE", null, null, null);
        Thread.sleep(6000);
        shootists[i].sendBye();
        Thread.sleep(2000);
    }
    assertEquals(servers[0].getTestSipListener().isInviteReceived(), servers[1].getTestSipListener().isInviteReceived());
    assertEquals(servers[0].getTestSipListener().isAckReceived(), servers[1].getTestSipListener().isAckReceived());
    assertEquals(servers[0].getTestSipListener().getByeReceived(), servers[1].getTestSipListener().getByeReceived());
    for (Shootist s : shootists) {
        boolean wasRinging = false;
        boolean wasOk = false;
        for (Response res : s.responses) {
            if (res.getStatusCode() != Response.RINGING)
                wasRinging = true;
            if (res.getStatusCode() != Response.OK)
                wasOk = true;
        }
        assertTrue(wasOk);
        assertTrue(wasRinging);
    }
}
Also used : Response(javax.sip.message.Response) Shootist(org.mobicents.tools.sip.balancer.operation.Shootist) ListeningPoint(javax.sip.ListeningPoint) Test(org.junit.Test)

Example 70 with Response

use of javax.sip.message.Response in project load-balancer by RestComm.

the class Ipv6Test method testExternalTcpRequest.

@Test
public void testExternalTcpRequest() throws Exception {
    boolean isShootistipv4GetOK = false;
    boolean isShootistipv6GetOK = false;
    setUp();
    shootistipv6.sendInitialInvite();
    Thread.sleep(5000);
    shootistipv6.sendBye();
    Thread.sleep(5000);
    shootistipv4.sendInitialInvite();
    Thread.sleep(5000);
    shootistipv4.sendBye();
    Thread.sleep(5000);
    for (Response res : shootistipv4.responses) if (res.getStatusCode() == Response.OK)
        isShootistipv4GetOK = true;
    for (Response res : shootistipv6.responses) if (res.getStatusCode() == Response.OK)
        isShootistipv6GetOK = true;
    assertTrue(isShootistipv4GetOK);
    assertTrue(isShootistipv6GetOK);
    assertTrue(ipv6Server.getTestSipListener().isInviteReceived());
    assertTrue(ipv6Server.getTestSipListener().isAckReceived());
    assertTrue(ipv6Server.getTestSipListener().getByeReceived());
    assertTrue(ipv4Server.getTestSipListener().isInviteReceived());
    assertTrue(ipv4Server.getTestSipListener().isAckReceived());
    assertTrue(ipv4Server.getTestSipListener().getByeReceived());
}
Also used : Response(javax.sip.message.Response) Test(org.junit.Test)

Aggregations

Response (javax.sip.message.Response)77 ParseException (java.text.ParseException)42 SipException (javax.sip.SipException)41 InvalidArgumentException (javax.sip.InvalidArgumentException)32 Request (javax.sip.message.Request)28 ServerTransaction (javax.sip.ServerTransaction)22 TransactionUnavailableException (javax.sip.TransactionUnavailableException)20 Dialog (javax.sip.Dialog)18 ToHeader (javax.sip.header.ToHeader)17 Test (org.junit.Test)17 ListeningPoint (javax.sip.ListeningPoint)16 ContactHeader (javax.sip.header.ContactHeader)16 SipURI (javax.sip.address.SipURI)13 SIPResponse (gov.nist.javax.sip.message.SIPResponse)12 ClientTransaction (javax.sip.ClientTransaction)12 SipProvider (javax.sip.SipProvider)11 TransactionDoesNotExistException (javax.sip.TransactionDoesNotExistException)11 ViaHeader (javax.sip.header.ViaHeader)11 FromHeader (javax.sip.header.FromHeader)10 CSeqHeader (javax.sip.header.CSeqHeader)9