SendNoteR() public static method

Sends note to client.
public static SendNoteR ( MsgrClient client ) : void
client MsgrClient
return void
Exemplo n.º 1
0
        public void SendNote(MsgrClient client, Packet packet)
        {
            var fromAccountId = packet.GetString().Trim();
            var receiver      = packet.GetString().Trim();
            var message       = packet.GetString().Trim();

            // Check message length
            if (message.Length > 200)
            {
                Log.Warning("User '{0}' tried to send a message that's longer than 200 characters.", client.User.AccountId);
                return;
            }

            // Check validity of receiver
            if (!_receiverRegex.IsMatch(receiver))
            {
                Log.Warning("User '{0}' tried to send a message to invalid receiver '{1}'.", client.User.AccountId, receiver);
                return;
            }

            // TODO: The messenger is kinda made for direct database access,
            //   but doing that with MySQL isn't exactly efficient...
            //   Maybe we should use a different solution for the msgr?
            //   On the other hand, we might want to create a web interface,
            //   in which case MySQL offers more flexibility.

            // TODO: You should be able to send a message to a character that
            //   has never logged in, so we can't check for contact existence,
            //   but this way someone could flood the database. Spam check?

            MsgrServer.Instance.Database.AddNote(client.User.FullName, receiver, message);

            Send.SendNoteR(client);
        }