Package javax.sip.message

Examples of javax.sip.message.Request


      callIDheadersDia.add((CallIdHeader) responseEvent.getResponse().getHeader(CallIdHeader.NAME));
     
      CSeqHeader cseq = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME);
      try{
        Dialog dialog = responseEvent.getClientTransaction().getDialog();
        Request ack = dialog.createAck(cseq.getSeqNumber());
        //System.out.println("Ack sent");
        dialog.sendAck(ack);
      }catch (SipException e) {
        e.printStackTrace();
        System.err.println(e.getMessage());
View Full Code Here


      for(int u = 0; u < 100000; u++){
          for (int i = 0; i < callInformation.size(); i++) {
              //Get the Line
              currentLine = callInformation.get(i).replaceAll(" ","").split("\\|");
              //Get the Numbers
              Request request = createMessage(currentLine[0],currentLine[1],i);
     
              //Send
              ClientTransaction clientTransaction = sipProvider.getNewClientTransaction(request);
             
              sct = (SIPClientTransaction) clientTransaction;
View Full Code Here

      System.err.println(e.getMessage());
    }
  }

  private static Request createMessage(String from, String to, long id){
    Request request = null;
    id += 1;//0 not allowed
    //Invite
    try
      // create From Header
      SipURI fromAddress = addressFactory.createSipURI(from, "send.com");
      Address fromNameAddress = addressFactory.createAddress(fromAddress);
      fromNameAddress.setDisplayName(from);
      FromHeader fromHeader = headerFactory.createFromHeader(fromNameAddress,"12345");

      // create To Header
      SipURI toAddress = addressFactory.createSipURI(to, "empf.com");
      Address toNameAddress = addressFactory.createAddress(toAddress);
      toNameAddress.setDisplayName(to);
      ToHeader toHeader = headerFactory.createToHeader(toNameAddress, null);

      // create Request URI
      SipURI requestURI = addressFactory.createSipURI(from, "127.0.0.1:5080");

      // Create ViaHeaders
      ArrayList viaHeaders = new ArrayList();
      ViaHeader viaHeader = headerFactory.createViaHeader("127.0.0.1",
          sipProvider.getListeningPoint(transport).getPort(), transport, null);
      viaHeaders.add(viaHeader);

      // Create a new CallId header
      CallIdHeader callIdHeader = sipProvider.getNewCallId();
      //callIdHeader.setCallId("1");
      // Create a new Cseq header
      CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(id, Request.INVITE);

      // Create a new MaxForwardsHeader
      MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(70);
      // Create the request.
      request = messageFactory.createRequest(requestURI,Request.INVITE,
          callIdHeader, cSeqHeader, fromHeader, toHeader, viaHeaders, maxForwards);
      // Create contact headers
      String host = "127.0.0.1";
      SipURI contactUrl = addressFactory.createSipURI(from, host);
      contactUrl.setPort(listeningPoint.getPort());

      // Create the contact name address.
      SipURI contactURI = addressFactory.createSipURI(from, host);
      contactURI.setPort(sipProvider.getListeningPoint(transport).getPort());
      contactURI.setTransportParam(transport);
      Address contactAddress = addressFactory.createAddress(contactURI);

      // Add the contact address.
      contactAddress.setDisplayName(from);
      contactHeader = headerFactory.createContactHeader(contactAddress);
      request.addHeader(contactHeader);
     
    } catch (ParseException e) {
      e.printStackTrace();
      System.err.println(e.getMessage());
    } catch (InvalidArgumentException e){
View Full Code Here

      CallIdHeader callID = (CallIdHeader) responseEvent.getResponse().getHeader(CallIdHeader.NAME);
      CSeqHeader cseq = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME);
     
      try{
        Dialog dialog = responseEvent.getClientTransaction().getDialog();
        Request ack = dialog.createAck(cseq.getSeqNumber());

        //System.out.println("Ack sent");
        //System.out.println("ACK sent");
        dialog.sendAck(ack);
        //A sends a BYE
        Request byeRequest = dialog.createRequest(Request.BYE);
        dialog.sendRequest(sipProvider.getNewClientTransaction(byeRequest));
        //System.out.println("BYE sent");
        //System.out.println("Bye sent");
       
      }catch (SipException e) {
View Full Code Here

                     */
                    if (sipProvider.getSipListener() != null
                            && sipProvider.getSipListener() instanceof SipListenerExt) {
                        raiseErrorEvent(SIPDialogErrorEvent.DIALOG_REINVITE_TIMEOUT);
                    } else {
                        Request byeRequest = SIPDialog.this
                                .createRequest(Request.BYE);
                        if (MessageFactoryImpl.getDefaultUserAgentHeader() != null) {
                            byeRequest.addHeader(MessageFactoryImpl
                                    .getDefaultUserAgentHeader());
                        }
                        ReasonHeader reasonHeader = new Reason();
                        reasonHeader.setCause(1024);
                        reasonHeader.setText("Timed out waiting to re-INVITE");
                        byeRequest.addHeader(reasonHeader);
                        ClientTransaction byeCtx = SIPDialog.this
                                .getSipProvider().getNewClientTransaction(
                                        byeRequest);
                        SIPDialog.this.sendRequest(byeCtx);
                        return;
View Full Code Here

                        /*
                         * Send BYE to the Dialog. This will be removed for the
                         * next spec revision.
                         */
                        try {
                            Request byeRequest = SIPDialog.this
                                    .createRequest(Request.BYE);
                            if (MessageFactoryImpl.getDefaultUserAgentHeader() != null) {
                                byeRequest.addHeader(MessageFactoryImpl
                                        .getDefaultUserAgentHeader());
                            }
                            ReasonHeader reasonHeader = new Reason();
                            reasonHeader.setProtocol("SIP");
                            reasonHeader.setCause(1025);
                            reasonHeader
                                    .setText("Timed out waiting to send ACK");
                            byeRequest.addHeader(reasonHeader);
                            ClientTransaction byeCtx = SIPDialog.this
                                    .getSipProvider().getNewClientTransaction(
                                            byeRequest);
                            SIPDialog.this.sendRequest(byeCtx);
                            return;
View Full Code Here

                    // It could be late arriving.
                    if (sipResponse.getStatusCode() / 100 == 2
                            && sipResponse.getCSeq().getMethod().equals(
                                    Request.INVITE)) {
                        try {
                            Request ackRequest = sipDialog
                                    .createAck(sipResponse.getCSeq()
                                            .getSeqNumber());
                            sipDialog.sendAck(ackRequest);
                        } catch (Exception ex) {
                            sipStack.getStackLogger().logError(
View Full Code Here

        protocolObjects.logLevel = 32; // JvB
    }

    public void processRequest(RequestEvent requestReceivedEvent) {
        Request request = requestReceivedEvent.getRequest();
        ServerTransaction serverTransactionId = requestReceivedEvent.getServerTransaction();

        logger.info("\n\nRequest " + request.getMethod() + " received at "
                + protocolObjects.sipStack.getStackName() + " with server transaction id "
                + serverTransactionId);

        // We are the UAC so the only request we get is the BYE.
        if (request.getMethod().equals(Request.BYE))
            processBye(request, serverTransactionId);
        else
            TestHarness.fail("Unexpected request ! : " + request);

    }
View Full Code Here

        try {
            if (response.getStatusCode() == Response.OK) {
                if (cseq.getMethod().equals(Request.INVITE)) {
                    TestHarness.assertEquals(DialogState.CONFIRMED, dialog.getState());
                    Request ackRequest = dialog.createAck(cseq.getSeqNumber());

                    TestHarness.assertNotNull(ackRequest.getHeader(MaxForwardsHeader.NAME));

                    if (dialog == this.ackedDialog) {
                        dialog.sendAck(ackRequest);
                        return;
                    }
View Full Code Here

            // Create a new MaxForwardsHeader
            MaxForwardsHeader maxForwards = protocolObjects.headerFactory
                    .createMaxForwardsHeader(70);

            // Create the request.
            Request request = protocolObjects.messageFactory.createRequest(requestURI,
                    Request.INVITE, callIdHeader, cSeqHeader, fromHeader, toHeader, viaHeaders,
                    maxForwards);
            // Create contact headers

            SipURI contactUrl = protocolObjects.addressFactory.createSipURI(fromName, host);
            contactUrl.setPort(listeningPoint.getPort());

            // Create the contact name address.
            SipURI contactURI = protocolObjects.addressFactory.createSipURI(fromName, host);
            contactURI
                    .setPort(sipProvider.getListeningPoint(protocolObjects.transport).getPort());
            contactURI.setTransportParam(protocolObjects.transport);

            Address contactAddress = protocolObjects.addressFactory.createAddress(contactURI);

            // Add the contact address.
            contactAddress.setDisplayName(fromName);

            contactHeader = protocolObjects.headerFactory.createContactHeader(contactAddress);
            request.addHeader(contactHeader);

            // Dont use the Outbound Proxy. Use Lr instead.
            request.setHeader(routeHeader);

            // Add the extension header.
            Header extensionHeader = protocolObjects.headerFactory.createHeader("My-Header",
                    "my header value");
            request.addHeader(extensionHeader);

            String sdpData = "v=0\r\n" + "o=4855 13760799956958020 13760799956958020"
                    + " IN IP4  129.6.55.78\r\n" + "s=mysession session\r\n"
                    + "p=+46 8 52018010\r\n" + "c=IN IP4  129.6.55.78\r\n" + "t=0 0\r\n"
                    + "m=audio 6022 RTP/AVP 0 4 18\r\n" + "a=rtpmap:0 PCMU/8000\r\n"
                    + "a=rtpmap:4 G723/8000\r\n" + "a=rtpmap:18 G729A/8000\r\n"
                    + "a=ptime:20\r\n";
            byte[] contents = sdpData.getBytes();

            request.setContent(contents, contentTypeHeader);

            extensionHeader = protocolObjects.headerFactory.createHeader("My-Other-Header",
                    "my new header value ");
            request.addHeader(extensionHeader);

            Header callInfoHeader = protocolObjects.headerFactory.createHeader("Call-Info",
                    "<http://www.antd.nist.gov>");
            request.addHeader(callInfoHeader);

            // Create the client transaction.
            inviteTid = sipProvider.getNewClientTransaction(request);
            Dialog dialog = inviteTid.getDialog();
View Full Code Here

TOP

Related Classes of javax.sip.message.Request

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.