Package com.sun.sgs.impl.sharedutil

Examples of com.sun.sgs.impl.sharedutil.MessageBuffer


    @Test
    public void testClientSessionSendSameBufferWithOffset()
  throws Exception
    {
  String msgString = "offset buffer";
  MessageBuffer msg =
      new MessageBuffer(MessageBuffer.getSize(msgString) + 1);
  msg.putByte(0);
  msg.putString(msgString);
  ByteBuffer buf = ByteBuffer.wrap(msg.getBuffer());
  buf.position(1);
  sendBufferToClient(buf, msgString);
    }
View Full Code Here


      client.waitForClientToReceiveExpectedMessages(numMessages);
      for (byte[] message : client.clientReceivedMessages) {
    if (message.length == 0) {
        fail("message buffer emtpy");
    }
    String msgString = (new MessageBuffer(message)).getString();
    if (!msgString.equals(expectedMsgString)) {
        fail("expected: " + expectedMsgString + ", received: " +
       msgString);
    } else {
        System.err.println("received expected message: " +
View Full Code Here

        /** {@inheritDoc} */
  public void receivedMessage(ByteBuffer message) {
            byte[] messageBytes = new byte[message.remaining()];
      message.get(messageBytes);
      MessageBuffer buf = new MessageBuffer(messageBytes);
      AppContext.getDataManager().markForUpdate(this);
      reconnectKey = new BigInteger(1, buf.getByteArray());
      byte[] bytes = buf.getByteArray();
      if (bytes.length == 0) {
    return;
      }
      DummyClient client = dummyClients.get(reconnectKey);
      System.err.println(
View Full Code Here

   * method of this client's associated ClientSessionListener must
   * expect that each message is prefixed with the reconnect key.
   */
  @Override
        public void sendMessage(byte[] message, boolean checkSuspend) {
      MessageBuffer buf =
    new MessageBuffer(5 + reconnectKey.length + message.length);
      buf.putByte(SimpleSgsProtocol.SESSION_MESSAGE).
    putByteArray(reconnectKey).
    putByteArray(message);
      sendRaw(buf.getBuffer(), checkSuspend);
  }
View Full Code Here

   */
  public void sendMessagesFromClientInSequence(
      int numMessages, int numExpectedMessages)
  {
      for (int i = 0; i < numMessages; i++) {
    MessageBuffer buf = new MessageBuffer(4);
    buf.putInt(i);
    sendMessage(buf.getBuffer(), true);
      }
      waitForSessionListenerToReceiveExpectedMessages(
    numExpectedMessages);
      validateMessageSequence(
    sessionListenerReceivedMessages, numExpectedMessages, 0);
View Full Code Here

    "validateMessageSequence: unexpected number of messages",
    numExpectedMessages, messageQueue.size());
      if (numExpectedMessages != 0) {
    int expectedValue = offset;
    for (byte[] message : messageQueue) {
        MessageBuffer buf = new MessageBuffer(message);
        int value = buf.getInt();
        System.err.println(
      toString() + " validating message sequence: " + value);
        assertEquals("unexpected value", expectedValue, value);
        expectedValue++;
    }
View Full Code Here

                if (!connector.isConnected()) {
        String reason =
      connectFailureMessage != null ?
      connectFailureMessage :
      DEFAULT_CONNECT_FAILURE_MESSAGE;
        MessageBuffer buf =
      new MessageBuffer(MessageBuffer.getSize(reason));
        buf.putString(reason);
        listener.disconnected(false, buf.getBuffer());
                    if (!connectComplete) {
      try {
          connector.shutdown();
      } catch (IllegalStateException e) {
          // ignore; connect attempt may have completed
View Full Code Here

                    "The returned PasswordAuthentication must not be null");
            }

            String user = authentication.getUserName();
            String pass = new String(authentication.getPassword());
            MessageBuffer msg =
                new MessageBuffer(2 +
                    MessageBuffer.getSize(user) +
                    MessageBuffer.getSize(pass));
            msg.putByte(SimpleSgsProtocol.LOGIN_REQUEST).
                putByte(SimpleSgsProtocol.VERSION).
                putString(user).
                putString(pass);
            try {
                sendRaw(ByteBuffer.wrap(msg.getBuffer()).asReadOnlyBuffer());
            } catch (IOException e) {
                logger.logThrow(Level.FINE, e, "During login request:");
                logout(true);
            }
  }
View Full Code Here

                connectionStateChanging = false;
    isSuspended = false;
            }
            String reason = null;
            if (message != null) {
                MessageBuffer msg = new MessageBuffer(message);
                reason = msg.getString();
            }

            for (SimpleClientChannel channel : channels.values()) {
                try {
                    channel.left();
View Full Code Here

        /**
         * {@inheritDoc}
         */
        public void receivedMessage(byte[] message) {
            try {
                MessageBuffer msg = new MessageBuffer(message);
               
                if (logger.isLoggable(Level.FINER)) {
                    String logMessage = String.format(
                        "Message length:%d", message.length);
                    logger.log(Level.FINER, logMessage);
View Full Code Here

TOP

Related Classes of com.sun.sgs.impl.sharedutil.MessageBuffer

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.