// per channel polling needs to be done because client may be still connected, leaving one channel, joining another public ChatRoom(RoomKind kind, uint project) { Debug.Assert(ChatService.IsCommandRoom(kind)); Kind = kind; RoomID = project + (uint)kind; ProjectID = project; }
private bool RoomsActive(params RoomKind[] kinds) { foreach (RoomKind kind in kinds) { ChatRoom room = Chat.GetRoom(ProjectID, kind); if (room != null && ChatService.IsCommandRoom(room.Kind)) { // if more people in command room, even if not online then it is active if (room.Members.SafeCount > 1) { return(true); } } } return(false); }
private void RoomsButton_DropDownOpening(object sender, EventArgs e) { RoomsButton.DropDownItems.Clear(); ToolStripMenuItem recent = new ToolStripMenuItem("Recent"); Chat.RoomMap.LockReading(delegate() { foreach (ChatRoom room in Chat.RoomMap.Values) { if (!ChatService.IsCommandRoom(room.Kind)) { ToolStripMenuItem item = new RoomItem(Chat, room, RoomMenu_Click); if (room.Active) { RoomsButton.DropDownItems.Add(item); } else { recent.DropDownItems.Add(item); } } } }); if (RoomsButton.DropDownItems.Count > 0) { RoomsButton.DropDownItems.Add(new ToolStripSeparator()); } RoomsButton.DropDownItems.Add(new ToolStripMenuItem("Join", null, RoomMenu_Join)); RoomsButton.DropDownItems.Add(new ToolStripMenuItem("Create", null, RoomMenu_Create)); if (recent.DropDownItems.Count > 0) { RoomsButton.DropDownItems.Add(recent); } }
public ChatRoom(RoomKind kind, ulong id, string title) { Debug.Assert(!ChatService.IsCommandRoom(kind)); Kind = kind; RoomID = id; Title = title; Invites = new Dictionary <ulong, Tuple <ChatInvite, List <ushort> > >(); // public rooms are private rooms with static room ids if (Kind == RoomKind.Public) { PublishRoom = true; Kind = RoomKind.Private; } if (Kind == RoomKind.Secret) { Verified = new Dictionary <ulong, bool>(); } }
public override void Init() { Chat_Refresh(); if (Custom != null) // set by invite form to open this by default { SetCustomRoom(Custom); } else if (RoomsActive(RoomKind.Command_High, RoomKind.Command_Low)) { LocalButton.PerformClick(); } else { Chat.RoomMap.LockReading(delegate() { foreach (ChatRoom room in Chat.RoomMap.Values) { if (room.Active && !ChatService.IsCommandRoom(room.Kind)) { SetCustomRoom(room); break; } } }); } if (External != null) { External.Activated += new EventHandler(External_Activated); External.Deactivate += new EventHandler(External_Deactivate); } }
void Chat_MembersUpdate() { MemberTree.BeginUpdate(); MemberTree.Nodes.Clear(); NodeMap.Clear(); List <ulong> users = new List <ulong>(); Room.Members.LockReading(delegate() { if (Room.Members.SafeCount == 0) { MemberTree.EndUpdate(); return; } users = Room.Members.ToList(); TreeListNode root = MemberTree.virtualParent; if (Room.Host != 0) { root = new MemberNode(this, Room.Host); if (Room.IsLoop) { ((MemberNode)root).IsLoopRoot = true; } else { NodeMap[Room.Host] = root as MemberNode; } UpdateNode(root as MemberNode); MemberTree.Nodes.Add(root); root.Expand(); } foreach (ulong id in Room.Members) { if (id != Room.Host) { // if they left the room dont show them if (!ChatService.IsCommandRoom(Room.Kind)) { if (Room.Members.SafeCount == 0) { continue; } } MemberNode node = new MemberNode(this, id); NodeMap[id] = node; UpdateNode(node); GuiUtils.InsertSubNode(root, node); } } }); MemberTree.EndUpdate(); if (VoiceButton != null) { AudioDirection direction = AudioDirection.Both; if (ParentView.ViewHigh != null && ParentView.ViewLow != null) { if (Room.Kind == RoomKind.Command_High || Room.Kind == RoomKind.Live_High) { direction = AudioDirection.Left; } else if (Room.Kind == RoomKind.Command_Low || Room.Kind == RoomKind.Live_Low) { direction = AudioDirection.Right; } } VoiceButton.SetUsers(users, direction); } }