Examples of MessageBuffer


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

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

      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

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

        /** {@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

Examples of org.menacheri.jetserver.communication.MessageBuffer

    cmdCount++;
    int type;
    int operation;
    boolean isDefaultProtocol = true;
    if(command instanceof MessageBuffer) {
      MessageBuffer buf = (MessageBuffer) command;
      type = buf.readInt();
      operation = buf.readInt();
    }else{
      // websocket
      isDefaultProtocol = false;
      List<Double> data = (List)command;
     
View Full Code Here

Examples of org.msgpack.core.buffer.MessageBuffer

                    String s = v.get().asString().toString();
                    System.out.println("read string: " + s);
                    break;
                case BINARY:
                    // Message buffer is an efficient byte buffer
                    MessageBuffer mb = v.get().asBinary().toMessageBuffer();
                    System.out.println("read binary: " + mb.toHexString(0, mb.size()));
                    break;
                case ARRAY:
                    ArrayValue arr = v.get().asArrayValue();
                    for(ValueRef a : arr) {
                        System.out.println("read array element: " + a);
View Full Code Here

Examples of org.msgpack.core.buffer.MessageBuffer

        encodeBuffer.flip();
        int strLen = encodeBuffer.remaining();

        // Preserve the current buffer
        MessageBuffer tmpBuf = buffer;

        // Switch the buffer to write the string length
        if(strLenBuffer == null) {
            strLenBuffer = MessageBuffer.newBuffer(5);
        }
View Full Code Here

Examples of org.msgpack.core.buffer.MessageBuffer

            // First, flush the current buffer contents
            flush();

            // Wrap the input source as a MessageBuffer
            MessageBuffer wrapped = MessageBuffer.wrap(src).slice(src.position(), src.remaining());
            // Then, dump the source data to the output
            out.flush(wrapped);
            src.position(src.limit());
        }
        else {
View Full Code Here

Examples of org.msgpack.core.buffer.MessageBuffer

            // Flush the current buffer contents
            flush();

            // Wrap the input array as a MessageBuffer
            MessageBuffer wrapped = MessageBuffer.wrap(src).slice(off, len);
            // Dump the source data to the output
            out.flush(wrapped);
        }
        else {
            int cursor = 0;
View Full Code Here

Examples of org.msgpack.core.buffer.MessageBuffer

    private MessageBuffer takeNextBuffer() throws IOException {
        if(reachedEOF)
            return null;

        MessageBuffer nextBuffer = null;
        if(secondaryBuffer == null) {
            nextBuffer = in.next();
        }
        else {
            nextBuffer = secondaryBuffer;
View Full Code Here

Examples of org.msgpack.core.buffer.MessageBuffer

                                 |-------|---------- secondary buffer (slice) ----------------|

             */

        // If the byte size to read fits within the extra buffer, use the extraBuffer
        MessageBuffer newBuffer = byteSizeToRead <= extraBuffer.size() ? extraBuffer : MessageBuffer.newBuffer(byteSizeToRead);

        // Copy the remaining buffer contents to the new buffer
        int firstHalfSize = buffer.size() - position;
        if(firstHalfSize > 0)
            buffer.copyTo(position, newBuffer, 0, firstHalfSize);

        // Read the last half contents from the next buffers
        int cursor = firstHalfSize;
        while(cursor < byteSizeToRead) {
            secondaryBuffer = takeNextBuffer();
            if(secondaryBuffer == null)
                return false; // No more buffer to read

            // Copy the contents from the secondary buffer to the new buffer
            int copyLen = Math.min(byteSizeToRead - cursor, secondaryBuffer.size());
            secondaryBuffer.copyTo(0, newBuffer, cursor, copyLen);

            // Truncate the copied part from the secondaryBuffer
            secondaryBuffer = copyLen == secondaryBuffer.size() ? null : secondaryBuffer.slice(copyLen, secondaryBuffer.size()-copyLen);
            cursor += copyLen;
        }

        // Replace the current buffer with the new buffer
        totalReadBytes += position;
        buffer = byteSizeToRead == newBuffer.size() ? newBuffer : newBuffer.slice(0, byteSizeToRead);
        position = 0;

        return true;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.