Esempio n. 1
0
        public override async Task OnReceiveBinary(byte[] data, int length)
        {
            //If we're not authenticated, handle that first.
            Log("RECEIVE", "GOT MESSAGE of length " + length);
            if (!authenticated)
            {
                await HandleAuthentication(data, length);

                return;
            }

            //Read the opcode and index
            ushort opcode = BinaryTool.ReadUInt16(data, 0);
            ulong  index  = BinaryTool.ReadUInt64(data, 2);

            //Switch on this opcode
            Log("RECEIVE", "Got message with opcode " + opcode + " / index " + index);
            if (opcode == 1)
            {
                await HandleRPCMessage(data, length, index);
            }
            else
            {
                await WriteResponse(index, 404);
            }
        }