/// <summary> /// Tries to create a new room. /// </summary> /// <param name="roomName"> /// The room id. /// </param> /// <param name="ownerPeer"> /// The peer that holds this reference. /// </param> /// <param name="roomReference"> /// When this method returns true, contains a new <see cref="RoomReference"/> for the room /// with the specified room id; otherwise, set to null. /// </param> /// <param name="args"> /// Optionally arguments used for room creation. /// </param> /// <returns> /// False if the cache contains a room with the specified room id; otherwise, true. /// </returns> public bool TryCreateRoom(string roomName, PeerBase ownerPeer, out RoomReference roomReference, params object[] args) { lock (this.SyncRoot) { if (this.roomInstances.ContainsKey(roomName)) { roomReference = null; return(false); } Room room = this.CreateRoom(roomName, args); var roomInstance = new RoomInstance(this, room); this.roomInstances.Add(roomName, roomInstance); roomReference = roomInstance.AddReference(ownerPeer); return(true); } }
/// <summary> /// Tries to create a new room. /// </summary> /// <param name="roomName"> /// The room id. /// </param> /// <param name="ownerPeer"> /// The peer that holds this reference. /// </param> /// <param name="roomReference"> /// When this method returns true, contains a new <see cref="RoomReference"/> for the room /// with the specified room id; otherwise, set to null. /// </param> /// <param name="args"> /// Optionally arguments used for room creation. /// </param> /// <returns> /// False if the cache contains a room with the specified room id; otherwise, true. /// </returns> public bool TryCreateRoom(string roomName, PeerBase ownerPeer, out RoomReference roomReference, params object[] args) { lock (this.SyncRoot) { if (this.RoomInstances.ContainsKey(roomName)) { roomReference = null; return false; } Room room = this.CreateRoom(roomName, args); var roomInstance = new RoomInstance(this, room); this.RoomInstances.Add(roomName, roomInstance); roomReference = roomInstance.AddReference(ownerPeer); return true; } }