public void Link_Update(OpTrust trust) { // update command/live rooms Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { OpLink localLink = Trust.LocalTrust.GetLink(project); OpLink remoteLink = trust.GetLink(project); if (localLink == null || remoteLink == null) { continue; } OpLink uplink = localLink.GetHigher(true); List <OpLink> downlinks = localLink.GetLowers(true); // if local link updating if (trust == Trust.LocalTrust) { // if we are in the project if (localLink.Active) { JoinCommand(project, RoomKind.Command_High); JoinCommand(project, RoomKind.Command_Low); JoinCommand(project, RoomKind.Live_High); JoinCommand(project, RoomKind.Live_Low); } // else leave any command/live rooms for this project else { LeaveRooms(project); } } // else if remote user updating else { if (uplink != null) { if (uplink.Trust == trust || uplink.GetLowers(true).Contains(remoteLink)) { RefreshCommand(project, RoomKind.Command_High); RefreshCommand(project, RoomKind.Live_High); } } if (downlinks.Contains(remoteLink)) { RefreshCommand(project, RoomKind.Command_Low); RefreshCommand(project, RoomKind.Live_Low); } } Core.RunInGuiThread(Refresh); } }); // refresh member list of any commmand/live room this person is apart of // link would already be added above, this ensures user is removed foreach (ChatRoom room in FindRoom(trust.UserID)) { if (IsCommandRoom(room.Kind)) { RefreshCommand(room); } else if (room.Members.SafeContains(trust.UserID)) { Core.RunInGuiThread(room.MembersUpdate); } } }