/// <inheritdoc /> public override Task WriteAsync(byte[] bytes, int offset, int count) { //We are making the assumption they are writing a full payload //and opcode. So we only need to serialize ushort length //and then the length and opcode should be encrypted ServerPacketHeader header = new ServerPacketHeader(count); byte[] serverPacketHeader = Serializer.Serialize(header); return(CryptAndSend(bytes, serverPacketHeader, offset, count)); }
/// <inheritdoc /> public virtual async Task WriteAsync(TWritePayloadBaseType payload) { try { //Serializer the payload first so we can build the header byte[] payloadData = Serializer.Serialize(payload); //Don't add 2 to the payload length since it contains the 2 byte opcode already ServerPacketHeader header = new ServerPacketHeader(payloadData.Length); byte[] serverPacketHeader = Serializer.Serialize(header); await CryptAndSend(payloadData, serverPacketHeader, 0, payloadData.Length); } catch (Exception e) { if (Logger.IsErrorEnabled) { Logger.Error($"Client proxy encountered Exception: {e.Message} \n\n {e.StackTrace}"); } throw; } }