Ejemplo n.º 1
0
  public void run() {
    while (true) {
      try {
        byteBuffer.clear();
        final com.sun.nio.sctp.MessageInfo messageInfo =
            channel.receive(
                byteBuffer,
                null,
                new NotificationHandler<Void>() {
                  @Override
                  public HandlerResult handleNotification(
                      Notification notification, Void attachment) {
                    System.out.println("handleNotification notification = " + notification);
                    return HandlerResult.CONTINUE;
                  }
                });
        System.out.println("after receive, messageInfo = " + messageInfo);
        if ((messageInfo != null) && (messageInfo.isComplete())) {
          System.out.println("received complete message " + byteBuffer);

          byteBuffer.flip();
          channel.send(
              byteBuffer,
              com.sun.nio.sctp.MessageInfo.createOutgoing(messageInfo.association(), null, 0));
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Ejemplo n.º 2
0
 /** Return {@code true} if this message is complete. */
 public boolean isComplete() {
   if (msgInfo != null) {
     return msgInfo.isComplete();
   } else {
     // all outbound sctp messages are complete
     return true;
   }
 }