internal static void Send(this Packets.Message Message) { try { Message.Encode(); if (Constants.Encryption == Logic.Enums.Server_Crypto.RC4) { Message.EncryptRC4(); } else { Message.EncryptSodium(); } Server_Resources.Gateway.Send(Message); if (Message.Device.Connected()) { Debug.WriteLine("[MESSAGE] " + Message.Device.Socket.RemoteEndPoint.ToString() + " <-- " + Message.GetType().Name + " [" + Message.Identifier + "]"); } Message.Process(); } catch (System.Exception Exception) { Console.WriteLine("Something when wrong! " + Exception); //Resources.Exceptions.Catch(Exception, ErrorLevel.Critical); } }
internal static void Recept(this Packets.Message Message) { if (Constants.Encryption == Logic.Enums.Server_Crypto.RC4) { Message.DecryptRC4(); } else { Message.DecryptSodium(); } Message.Decode(); Message.Process(); }
private void _saveMessage(Packets.Message msg) { var senderId = msg.Reciever == self.UserID ? msg.Sender : msg.Reciever; var message = new DB.Message(msg.Id, msg.Sender, senderId == self.UserID, msg.Text); var sender = _onlineUsers.First(usr => usr.UserID == senderId); if (_chats.ContainsKey(sender)) { _chats[sender].Add(message); } else { _chats.Add(sender, new List <DB.Message> { message }); chatList.Items.Add(sender); chatList.Focus(); } //TODO: add to DB _drawMessage(message); }