Package com.sun.sgs.impl.sharedutil

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


                byte[] payload = new byte[message.remaining()];
                message.get(payload);

                // Dispatch
    MessageBuffer msg = new MessageBuffer(payload);
    byte opcode = msg.getByte();
   
    if (logger.isLoggable(Level.FINEST)) {
        logger.log(
      Level.FINEST,
      "processing opcode 0x{0}",
View Full Code Here


    /**
     * Notifies the associated client that the previous relocation attempt
     * was successful.
     */
    private void relocateSuccess() {
  MessageBuffer buf = new MessageBuffer(1 + reconnectKey.length);
  buf.putByte(SimpleSgsProtocol.RELOCATE_SUCCESS).
      putBytes(reconnectKey);
  writeNow(ByteBuffer.wrap(buf.getBuffer()), true);
    }
View Full Code Here

     *    relocation request, or {@code null}
     */
    private void relocateFailure(String reason, Throwable ignore) {
  // the reason argument is overridden for security reasons
  reason = DEFAULT_RELOCATE_FAILED_REASON;
        MessageBuffer buf =
      new MessageBuffer(1 + MessageBuffer.getSize(reason));
        buf.putByte(SimpleSgsProtocol.RELOCATE_FAILURE).
            putString(reason);
  writeNow((ByteBuffer.wrap(buf.getBuffer())), true);
  monitorDisconnection();
    }
View Full Code Here

    throw new RuntimeException(toString() + " not connected");
      }
  }
  String password = "password";

  MessageBuffer buf =
      new MessageBuffer(2 + MessageBuffer.getSize(name) +
            MessageBuffer.getSize(password));
  buf.putByte(SimpleSgsProtocol.LOGIN_REQUEST).
      putByte(protocolVersion).
      putString(name).
      putString(password);
  loginAck = false;
  try {
      connection.sendBytes(buf.getBuffer());
  } catch (IOException e) {
      throw new RuntimeException(e);
  }
  if (waitForLogin) {
      if (waitForLogin()) {
View Full Code Here

      if (connected == false) {
    return;
      }
      logoutAck = false;
  }
  MessageBuffer buf = new MessageBuffer(1);
  buf.putByte(SimpleSgsProtocol.LOGOUT_REQUEST);
  try {
      connection.sendBytes(buf.getBuffer());
  } catch (IOException e) {
      throw new RuntimeException(e);
  }
  synchronized (lock) {
      try {
View Full Code Here

        toString() + "AbstractDummyClient.Listener.bytesReceived:" +
        " wrong handle, got:" + conn + ", expected:" + connection);
    return;
      }

      MessageBuffer buf = new MessageBuffer(buffer);
      byte opcode = buf.getByte();
     
      handleOpCode(opcode, buf);
  }
View Full Code Here

            private boolean loggedIn = false;
            private ByteBuffer message;
            CompletionHandler handler = null;
           
            DummyChannel() {
                final MessageBuffer msg =
                        new MessageBuffer(4 +
                                          MessageBuffer.getSize("username") +
                                          MessageBuffer.getSize("password"));
                msg.putShort(msg.capacity() - 2);
                msg.putByte(SimpleSgsProtocol.LOGIN_REQUEST);
                msg.putByte(SimpleSgsProtocol.VERSION);
                msg.putString("username");
                msg.putString("password");
                message = ByteBuffer.allocate(msg.capacity());
                message.put(msg.getBuffer());
                message.flip();
            }
View Full Code Here

   
    /** {@inheritDoc} */
    public void channelJoin(
  String name, BigInteger channelId, Delivery delivery) {
  byte[] channelIdBytes = channelId.toByteArray();
  MessageBuffer buf =
      new MessageBuffer(1 + MessageBuffer.getSize(name) +
            channelIdBytes.length);
  buf.putByte(SimpleSgsProtocol.CHANNEL_JOIN).
      putString(name).
      putBytes(channelIdBytes);
  write(ByteBuffer.wrap(buf.getBuffer()));
    }
View Full Code Here

    /**
     * Notifies the associated client that the previous login attempt was
     * successful.
     */
    protected void loginSuccess() {
  MessageBuffer buf = new MessageBuffer(1 + reconnectKey.length);
  buf.putByte(SimpleSgsProtocol.LOGIN_SUCCESS).
      putBytes(reconnectKey);
  writeNow(ByteBuffer.wrap(buf.getBuffer()), true);
    }
View Full Code Here

        for (ProtocolDescriptor descriptor : descriptors) {
            if (acceptor.getDescriptor().supportsProtocol(descriptor)) {
    byte[] redirectionData =
        ((SimpleSgsProtocolDescriptor) descriptor).
            getConnectionData();
    MessageBuffer buf =
        new MessageBuffer(1 + redirectionData.length);
    buf.putByte(SimpleSgsProtocol.LOGIN_REDIRECT).
        putBytes(redirectionData);
    writeNow(ByteBuffer.wrap(buf.getBuffer()), true);
    monitorDisconnection();
                return;
            }
        }
        loginFailure("redirect failed", null);
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.