示例#1
0
        public void EncrptedSendLarge <T>(Connection connection, ref T message) where T : IMessage
        {
            if (!AESKeys.TryGetValue(connection, out string Key))
            {
                Log.WriteNow("Failed to find AES Key for this connection. Failed to send encrypted message");
                return;
            }

            AESMessage aesMessage = new AESMessage(message)
            {
                ID = message.ID
            };

            aesMessage.Encrypt(Key);
            byte[] data = MessageUtil.Serialize(ref aesMessage);

            SendLarge(connection, ref aesMessage, data);
        }
示例#2
0
        public void EncrptedSend <T>(ref T message) where T : IMessage
        {
            message.TotalParts = 1;
            message.Part       = 0;
            message.ID         = message.ID != 0 ? message.ID : NextID;

            AESMessage aesMessage = new AESMessage(message)
            {
                ID = message.ID
            };

            aesMessage.Encrypt(AESKey);

            byte[] data = MessageUtil.Serialize(ref aesMessage);
            BitConverter.GetBytes(data.Length).CopyTo(data, 6);

            rawClient.Send(data);
        }
示例#3
0
        public void EncrptedSend <T>(Connection connection, ref T message) where T : IMessage
        {
            if (!AESKeys.TryGetValue(connection, out string Key))
            {
                Log.WriteNow("Failed to find AES Key for this connection. Failed to send encrypted message");
                return;
            }

            AESMessage aesMessage = new AESMessage(message)
            {
                ID = message.ID
            };

            aesMessage.Encrypt(Key);
            byte[] buffer = MessageUtil.Serialize(ref aesMessage);
            BitConverter.GetBytes(buffer.Length).CopyTo(buffer, 6);

            rawServer.Send(connection, buffer);
        }
示例#4
0
        public void EncrptedSendLarge <T>(ref T message, byte[] Data = null) where T : IMessage
        {
            message.ID = message.ID != 0 ? message.ID : NextID;

            if (Data == null)
            {
                // Message not already serialized
                Data = MessageUtil.Serialize(ref message);
                BitConverter.GetBytes(Data.Length).CopyTo(Data, 6);
            }

            AESMessage aesMessage = new AESMessage(Data)
            {
                ID = message.ID
            };

            aesMessage.Encrypt(AESKey);
            byte[] data = MessageUtil.Serialize(ref message);

            SendLarge(ref aesMessage, data);
        }