public dynamic Decode(IChannel channel, PacketBuffer buffer) { buffer.BeginBufferIndex(); if (buffer.AvailableBytes() < 1) { buffer.ResetBufferIndex(); return null; } var data = new byte[buffer.AvailableBytes()]; buffer.ReadBytes(data); string s = System.Text.Encoding.UTF8.GetString(data); int len = s.IndexOf('\n'); if (len == -1) { buffer.ResetBufferIndex(); return null; } s = s.Substring(0, len + 1); buffer.SetPosition(System.Text.Encoding.UTF8.GetByteCount(s)); buffer.EndBufferIndex(); return s; }
public dynamic Decode(IChannel channel, PacketBuffer buffer) { buffer.BeginBufferIndex(); if (buffer.AvailableBytes() < 1) { buffer.ResetBufferIndex(); return null; } var data = new byte[buffer.AvailableBytes()]; buffer.ReadBytes(data); buffer.EndBufferIndex(); return data; }