private EzyByteBuffer mergeBytes(byte[] bytes)
        {
            int           capacity = buffer.remaining() + bytes.Length;
            EzyByteBuffer merge    = EzyByteBuffer.allocate(capacity);

            merge.put(buffer);
            merge.put(bytes);
            merge.flip();
            return(merge);
        }
Beispiel #2
0
        protected void sendHandshakeRequest()
        {
            int tokenSize   = sessionToken.Length;
            int messageSize = 0;

            messageSize += 8;         // sessionIdSize
            messageSize += 2;         // tokenLengthSize
            messageSize += tokenSize; // messageSize
            EzyByteBuffer buffer = EzyByteBuffer.allocate(1 + 2 + messageSize);
            byte          header = 0;

            header |= 1 << 5;
            buffer.put(header);
            buffer.putShort((short)messageSize);
            buffer.putLong(sessionId);
            buffer.putShort((short)tokenSize);
            buffer.put(EzyStrings.getBytes(sessionToken));
            buffer.flip();
            byte[] bytes = buffer.getRemainBytes();
            datagramChannel.Send(bytes, bytes.Length);
        }
Beispiel #3
0
 protected EzyByteBuffer newReadBuffer()
 {
     return(EzyByteBuffer.allocate(getReadBufferSize()));
 }
        private EzyByteBuffer newByteBuffer(EzyMessage message)
        {
            int capacity = getCapacity(message);

            return(EzyByteBuffer.allocate(capacity));
        }