RemoveUser() private méthode

private RemoveUser ( Node node ) : void
node Node
Résultat void
Exemple #1
0
        internal void ProcessLeaveChatMessage(Node messageFrom, ChatAction action)
        {
            if (action.RoomName == null || !action.RoomName.StartsWith("#"))
            {
                return;
            }

            ChatRoom room = network.GetChatRoom(action.RoomId);

            if (room != null)
            {
                if (room.Users.ContainsKey(messageFrom.NodeID))
                {
                    room.RemoveUser(messageFrom);
                    network.RaiseLeftChat(messageFrom, room);
                    if (room.Users.Count == 0)
                    {
                        network.RemoveChatRoom(room);
                    }
                }
            }
            else
            {
                Core.LoggingService.LogWarning("Received LeaveChat message for unknown room {0}", action.RoomName);
            }
        }
Exemple #2
0
        /*

        internal void JoinChat(string roomId, string roomName)
        {
            JoinChat(roomId, roomName, null);
        }

        internal void JoinChat(string roomName, string roomId, string password)
        {
            lock (chatRooms) {
                ChatRoom room;
                if (!chatRooms.ContainsKey(roomId)) {
                    room = new ChatRoom (this, roomId, roomName);
                    AddChatRoom(c);
                } else {
                    c = chatRooms[roomId];
                    if (c.PasswordTest == "") {
                        throw new Exception("That chatroom is not password-protected.");
                    }
                    if (c.TestPassword(password) == false) {
                        throw new PasswordIncorrectException();
                    }
                }
            }

            c.Password = password;
            if (!c.Users.ContainsKey(LocalNode.NodeID)) {
                c.AddUser(LocalNode);
                SendBroadcast(MessageBuilder.CreateJoinChatMessage(c.Name), LocalNode);
                OnJoinedChat (new ChatEventArgs (LocalNode, c));
            }
        }

        */
        public void LeaveChat(ChatRoom room)
        {
            SendBroadcast(MessageBuilder.CreateLeaveChatMessage(room), LocalNode);
            room.RemoveUser(LocalNode);
            OnLeftChat (new ChatEventArgs (LocalNode, room));
            if (room.Users.Count == 0) {
                RemoveChatRoom(room);
            }
        }