Package com.sun.sgs.impl.sharedutil

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


        } catch (NameNotBoundException e) {
            throw new MaybeRetryException("retry", true);
        }
        ClientSession session = (ClientSession)
            dataManager.getBinding(client.name);
        MessageBuffer buf = new MessageBuffer(4);
        buf.putInt(counter.getAndIncrement());
        session.send(ByteBuffer.wrap(buf.getBuffer()),
               delivery);
          }},
     
      identity);
    }
View Full Code Here


    }

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

    @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

            boolean success = state.compareAndSet(DISCONNECTING, DISCONNECTED);
            assert success;
        }

        void mockDeliverRecv() {
            MessageBuffer buf = recvQueue.poll();
            assert buf != null;
            mockDeliverRecv(buf.getBuffer());
        }
View Full Code Here

        void mockDeliverRecv(byte[] message) {
            listener.receivedMessage(message);
        }

        void mockLoggedIn(byte[] reconnectKey) {
            MessageBuffer buf = new MessageBuffer(1 + reconnectKey.length);
            buf.putByte(SimpleSgsProtocol.LOGIN_SUCCESS).
                putBytes(reconnectKey);
            recvQueue.add(buf);
        }
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.