public void ReadHandler(byte[] data, int dataIndex, int dataSize) { int copyAmount = 0; var res = OnReceive(data, dataIndex, dataSize, out copyAmount); if (res == PacketProcessResult.Error) //Unknown data on a stream that doesn't have a reported size { ClientConnection.Dispose(); return; } if (res == PacketProcessResult.Processed) { CurrentPacket.Reset(); DataNeeded = DefaultDataNeeded(); var realmProcessor = this as RealmPacketProcessor; if (realmProcessor != null) { realmProcessor.DecryptPointer = 0; } } dataIndex += copyAmount; if (dataIndex < dataSize) { //we have more data to process ReadHandler(data, dataIndex, dataSize); } }
public Task OnNextAsync(SocketCommand item, StreamSequenceToken token) { switch (item.GetCommand()) { case SocketCommands.DisconnectClient: { sock.Dispose(); } break; case SocketCommands.SetAccount: { sock.CurrentAccount = (IAccount)item.GetData(0); } break; case SocketCommands.SetPlayer: { sock.CurrentPlayer = (IPlayer)item.GetData(0); } break; case SocketCommands.ClearAccount: { sock.CurrentAccount = null; } break; case SocketCommands.ClearPlayer: { sock.CurrentPlayer = null; } break; } return(TaskDone.Done); }