protected override Task <bool> Send(SendBaseCommand cmd, DataWriter writer) { bool blnRet = false; lock (Syncroot) m_RecieveBuffer = null; byte[] byNonce = Sodium.Core.GetRandomBytes(24); writer.WriteBytes(byNonce); writer.WriteUInt32(Connection.UniqueClientID.Value); byte[] byDecryptedMessage = cmd.Serialize(BitConverter.GetBytes(Connection.UniqueClientID.Value)).ToArray(); byte[] byEncryptedMessage = Sodium.SecretBox.Create(byDecryptedMessage, byNonce, Connection.SharedKey); writer.WriteUInt16((UInt16)byEncryptedMessage.Length); writer.WriteBytes(byEncryptedMessage); blnRet = true; return(Task.FromResult(blnRet)); }
protected override Task <bool> Send(SendBaseCommand cmd, DataWriter writer) { writer.WriteBytes(cmd.Serialize().ToArray()); return(Task.FromResult(true)); }