public bool CreatePMRoom(HashSet<int> newUsers, int creator, out string error) { error = ""; bool result = false; lock(managerLock) { Log("Enter createpmroom lock", MyExtensions.Logging.LogLevel.Locks); if (newUsers.Count < 2) { error = "There's not enough people to make the room"; } else if (rooms.Any(x => x.Value.Users.SetEquals(newUsers))) { error = "There's already a room with this exact set of people!"; } else if (!newUsers.All(x => users.ContainsKey(x))) { error = "One or more of the given users doesn't exist!"; } /*else if (newUsers.Any(x => users[x].IrcUser)) { error = "You can't include IRC users in a PM room!"; }*/ else if (!users.ContainsKey(creator)) { error = "You don't seem to exist... I'm not sure how to create the room"; } else if (users[creator].Banned || users[creator].Blocked) { error = "You are banned or blocked and cannot create a room"; } else { PMRoom newRoom = new PMRoom(newUsers, creator, TimeSpan.FromDays(1)); rooms.Add(newRoom.Name, newRoom); result = true; } Log("Exit createpmroom lock", MyExtensions.Logging.LogLevel.Locks); } if (result) BroadcastUserList(); return result; }
public RoomJSONObject(PMRoom room, Dictionary<int, User> users) { name = room.Name; this.users = room.Users.ToList().Select(x => new RoomUserJSONObject(users[x])).ToList(); }