Пример #1
0
        /// <summary>
        /// Completely remove a user from a target chat name
        /// </summary>
        /// <param name="User">Target user to remove from </param>
        /// <param name="ChatName">Target chat's name</param>
        /// <param name="AlertMSG">Alert sent to user while user is removed</param>
        /// <param name="MSG">Whether to send an alert while removing</param>
        public static void Disconnect(GameClient User, string ChatName, bool AlertMSG = false, string MSG = null)
        {
            if (User == null)
            {
                return;
            }

            if (RunningChatRooms == null)
            {
                return;
            }

            if (!RunningChatRooms.ContainsKey(ChatName.ToLower()))
            {
                return;
            }

            WebSocketChatRoom Chat = GetChatByName(ChatName);

            if (Chat == null)
            {
                return;
            }

            if (AlertMSG && MSG != null)
            {
                if (User.GetRoleplay() != null)
                {
                    User.GetRoleplay().SendTopAlert(MSG);
                }
            }

            if (!Chat.ChatUsers.ContainsKey(User))
            {
                return;
            }

            RunningChatRooms[ChatName.ToLower()].DecomposeChatDIV(User);

            if (Chat.ChatUsers.ContainsKey(User))
            {
                Chat.OnUserLeft(User);
            }

            WebSocketChatRoom outChat;

            if (!User.LoggingOut)
            {
                if (User.GetRoleplay() == null)
                {
                    return;
                }
                if (User.GetRoleplay().ChatRooms == null)
                {
                    return;
                }
                User.GetRoleplay().ChatRooms.TryRemove(ChatName.ToLower(), out outChat);
            }

            RunningChatRooms[ChatName.ToLower()].CheckDelete();
        }