protected override IByteBuffer ExtractFrame(IChannelHandlerContext context, IByteBuffer buffer, int index, int length) { buffer = buffer.WithOrder(ByteOrder.LittleEndian); byte[] data = buffer.ToArray(); CMessage msg = new CMessage(new CByteArray(data)); short magic = 0; if (!msg.Read(ref magic) && magic != 0x5713) { throw new ProudException("Bad format in Magic"); } CByteArray coreMessage = new CByteArray(); if (!msg.Read(ref coreMessage)) { throw new ProudException("Bad format in Frame"); } IByteBuffer coreMsgBuffer = Unpooled.Buffer(coreMessage._buffer.Length); coreMsgBuffer.WriteBytes(coreMessage._buffer); return(coreMsgBuffer); }
public bool Read(CMessage msg) { msg.Read(out idname); msg.Read(out pw); return(true); }