public Message SendMessage(Peer peer, string message) { if (peer == null || peer.ID == null || string.IsNullOrEmpty(message)) { return(null); } fLogger.WriteDebug("SendMessage: {0}, `{1}`", peer.EndPoint, message); var msg = new Message(DateTime.UtcNow, message, fLocalPeer.ID.ToString(), peer.ID.ToString()); fDatabase.SaveMessage(msg); bool encrypted = false; if (peer.Profile != null && !string.IsNullOrEmpty(peer.Profile.PublicKey)) { message = Utilities.Encrypt(message, peer.Profile.PublicKey); encrypted = true; } SendData(peer.EndPoint, ProtocolHelper.CreateChatMessage(DHTTransactions.GetNextId(), fDHTClient.LocalID, message, encrypted, msg.Timestamp.ToBinary())); return(msg); }