protected byte[] parseString(String str)
 {
     byte[][] bytess = new byte[2][];
     bytess[1] = EzyStrings.getUtfBytes(str);
     bytess[0] = parseStringSize(bytess[1].Length);
     return(EzyBytes.merge(bytess));
 }
Пример #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);
        }