Package org.mobicents.protocols.api

Examples of org.mobicents.protocols.api.PayloadData


    public void onCommunicationUp(Association association, int maxInboundStreams, int maxOutboundStreams) {
      System.out.println(this + " onCommunicationUp");

      clientAssocUp = true;

      PayloadData payloadData = new PayloadData(CLIENT_MESSAGE.length, CLIENT_MESSAGE, true, false, 3, 1);

      try {
        association.send(payloadData);
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here


    public void onCommunicationUp(Association association, int maxInboundStreams, int maxOutboundStreams) {
      System.out.println(this + " onCommunicationUp");

      serverAssocUp = true;

      PayloadData payloadData = new PayloadData(SERVER_MESSAGE.length, SERVER_MESSAGE, true, false, 3, 1);

      try {
        association.send(payloadData);
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

     
      clientMaxInboundStreams = maxInboundStreams;
      clientMaxOutboundStreams = maxOutboundStreams;
      clientAssocUp = true;

      PayloadData payloadData = new PayloadData(CLIENT_MESSAGE.length, CLIENT_MESSAGE, true, false, 3, 1);

      try {
        association.send(payloadData);
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

      serverAssocUp = true;
      serverMaxInboundStreams = maxInboundStreams;
      serverMaxOutboundStreams = maxOutboundStreams;
         

      PayloadData payloadData = new PayloadData(SERVER_MESSAGE.length, SERVER_MESSAGE, true, false, 3, 1);

      try {
        association.send(payloadData);
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

  }

  protected void read() {

    try {
      PayloadData payload;
      if (this.ipChannelType == IpChannelType.SCTP)
        payload = this.doReadSctp();
      else
        payload = this.doReadTcp();
      if (payload == null)
        return;

      if (logger.isDebugEnabled()) {
        logger.debug(String.format("Rx : Ass=%s %s", this.name, payload));
      }

      if (this.management.isSingleThread()) {
        // If single thread model the listener should be called in the
        // selector thread itself
        try {
          this.associationListener.onPayload(this, payload);
        } catch (Exception e) {
          logger.error(String.format("Error while calling Listener for Association=%s.Payload=%s", this.name,
              payload), e);
        }
      } else {
        Worker worker = new Worker(this, this.associationListener, payload);

//        System.out.println("payload.getStreamNumber()=" + payload.getStreamNumber()
//            + " this.workerThreadTable[payload.getStreamNumber()]"
//            + this.workerThreadTable[payload.getStreamNumber()]);

        ExecutorService executorService = this.management.getExecutorService(this.workerThreadTable[payload
            .getStreamNumber()]);
        try {
          executorService.execute(worker);
        } catch (RejectedExecutionException e) {
          logger.error(String.format("Rejected %s as Executors is shutdown", payload), e);
View Full Code Here

    rxBuffer.flip();
    byte[] data = new byte[len];
    rxBuffer.get(data);
    rxBuffer.clear();

    PayloadData payload = new PayloadData(len, data, messageInfo.isComplete(), messageInfo.isUnordered(),
        messageInfo.payloadProtocolID(), messageInfo.streamNumber());

    return payload;
  }
View Full Code Here

    rxBuffer.flip();
    byte[] data = new byte[len];
    rxBuffer.get(data);
    rxBuffer.clear();

    PayloadData payload = new PayloadData(len, data, true, false, 0, 0);

    return payload;
  }
View Full Code Here

      if (!txQueue.isEmpty() && !txBuffer.hasRemaining()) {
        while (!txQueue.isEmpty()) {
          // Lets read all the messages in txQueue and send

          txBuffer.clear();
          PayloadData payloadData = txQueue.poll();

          if (logger.isDebugEnabled()) {
            logger.debug(String.format("Tx : Ass=%s %s", this.name, payloadData));
          }

          // load ByteBuffer
          // TODO: BufferOverflowException ?
          txBuffer.put(payloadData.getData());

          if (this.ipChannelType == IpChannelType.SCTP) {
            int seqControl = payloadData.getStreamNumber();

            if (seqControl < 0 || seqControl >= this.associationHandler.getMaxOutboundStreams()) {
              try {
                // TODO : calling in same Thread. Is this ok? or
                // dangerous?
                this.associationListener.inValidStreamId(payloadData);
              } catch (Exception e) {

              }
              txBuffer.clear();
              txBuffer.flip();
              continue;
            }

            msgInfo = MessageInfo.createOutgoing(this.peerSocketAddress, seqControl);
            msgInfo.payloadProtocolID(payloadData.getPayloadProtocolId());
            msgInfo.complete(payloadData.isComplete());
            msgInfo.unordered(payloadData.isUnordered());
          }

          txBuffer.flip();

          this.doSend();
View Full Code Here

        if (sequenceNumber >= this.maxSequenceNumber) {
          sequenceNumber = 0;
        }

        PayloadData payloadData = new PayloadData(data.length, data, true, false, 3, sequenceNumber);

        sequenceNumber++;
        try {
          association.send(payloadData);
        } catch (Exception e) {
View Full Code Here

    assertTrue(this.assDataSrv.get(0).ass.isStarted()); // !!!
    assertTrue(this.assDataSrv.get(1).ass.isConnected());
    assertTrue(this.assDataSrv.get(1).ass.isStarted());

    // test7 - transfer data via conn2
    PayloadData pd = new PayloadData(CLIENT_MESSAGE2.length, CLIENT_MESSAGE2, true, false, 3, 1);
    this.clientAssociation2.send(pd);
    Thread.sleep(500);

    assertEquals(this.server.anonymAssociations.size(), 1);
    assertEquals(this.assDataSrv.size(), 2);
View Full Code Here

TOP

Related Classes of org.mobicents.protocols.api.PayloadData

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.