ChatR() public static method

Broadcasts chat message in session.
public static ChatR ( Aura.Msgr.Chat.ChatSession session, int contactId, string message ) : void
session Aura.Msgr.Chat.ChatSession
contactId int
message string
return void
Ejemplo n.º 1
0
        public void Chat(MsgrClient client, Packet packet)
        {
            var sessionId = packet.GetLong();
            var message   = packet.GetString();

            // Check message
            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            if (message.Length > 256)
            {
                Log.Warning("Chat: User '{0}' sent message that was longer than allowed by the client.", client.User.AccountId);
                return;
            }

            // Check session
            var session = MsgrServer.Instance.ChatSessionManager.Get(sessionId);

            if (session == null || !session.HasUser(client.User.Id))
            {
                Log.Warning("Chat: User '{0}' tried to chat in invalid session.", client.User.AccountId);
                return;
            }

            // Notify implicit, but not active users
            var implicitUsers = session.GetInactiveImplicitUsers();

            foreach (var user in implicitUsers)
            {
                session.Join(user);
            }

            Send.ChatR(session, client.User.Id, message);
        }