public override void ChannelRead(IChannelHandlerContext context, object message)
{
var buffer = message as IByteBuffer;
if (buffer != null)
{
int stringLength = buffer.ReadByte();
var b = new byte[stringLength];
buffer.ReadBytes(b, 0, b.Length);
string instanceId = Encoding.UTF8.GetString(b);
stringLength = buffer.ReadByte();
b = new byte[stringLength];
buffer.ReadBytes(b, 0, b.Length);
string messageType = Encoding.UTF8.GetString(b);
this.parent.SetInstanceIdChannel(instanceId, context.Channel);
if (!this.clientConnectedInvoked)
{
this.clientConnectedAction?.Invoke(instanceId, context.Channel.Id.AsShortText());
this.clientConnectedInvoked = true;
}
Task.Run(() =>
{
this.dataReceivedAction(instanceId, context.Channel.Id.AsShortText(), messageType, buffer.ToArray());
});
}
}