Ejemplo n.º 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 {
                LoggingService.LogWarning("Received LeaveChat message for unknown room {0}", action.RoomName);
            }
        }
Ejemplo n.º 2
0
 public Message CreateLeaveChatMessage(ChatRoom room)
 {
     Message p = new Message(network, MessageType.LeaveChat);
     ChatAction c = new ChatAction();
     c.RoomId = room.Id;
     c.RoomName = room.Name;
     p.Content = c;
     return p;
 }
Ejemplo n.º 3
0
        internal void ProcessJoinChatMessage(Node messageFrom, ChatAction action)
        {
            if (action.RoomName != null && action.RoomName.StartsWith("#")) {
                ChatRoom c;
                if (!network.HasChatRoom(action.RoomId)) {
                    c = new ChatRoom(network, action.RoomId, action.RoomName);
                    network.AddChatRoom(c);
                } else {
                    c = network.GetChatRoom(action.RoomId);
                }

                if (!c.Users.ContainsKey(messageFrom.NodeID)) {
                    c.AddUser(messageFrom);
                    network.RaiseJoinedChat (messageFrom, c);
                }

            //	Node n = network.Nodes[action.NodeID];
            //	if (n != null) {
            //		if (c.Users[n.NodeID] == null) {
            //			c.Users.Add(n);
            //			network.RaiseJoinedChat (n, c);
            //		}
            //	} else {
            //
            //	}
            }
        }