public void Add(Connection connection) { List <string> rooms; bool firstConnection; lock (_sync) { if (_connections.Contains(connection)) { return; } _connections.Add(connection); connection.Session = this; rooms = _rooms.ToList(); firstConnection = _firstConnection; _firstConnection = false; } foreach (var roomName in rooms) { var room = Program.RoomManager.Get(roomName); if (room == null) { continue; } connection.SendJoinRoom(room); if (firstConnection) { room.SessionEnter(this); } } }
public void Add(Connection connection) { List<string> rooms; bool firstConnection; lock (_sync) { if (_connections.Contains(connection)) return; _connections.Add(connection); connection.Session = this; rooms = _rooms.ToList(); firstConnection = _firstConnection; _firstConnection = false; } foreach (var roomName in rooms) { var room = Program.RoomManager.Get(roomName); if (room == null) continue; connection.SendJoinRoom(room); if (firstConnection) room.SessionEnter(this); } }