/// <summary> /// Clears slot which specified client is occupying. /// </summary> /// <param name="sender">Client who is going to be removed from his slot.</param> /// <returns>Slot id from which client has been removed or null if failed to remove.</returns> public Int32?ClearSlot(ConnectedClient sender) { lock (this.slotsSyncLock) { SlotInfo slotInfo = this.slots.Find(slot => slot.Client == sender); if (slotInfo == null) { // Specific situation which should not occur. No such client found in one of slots for this level. return(null); } else { this.slots.Remove(slotInfo); return(slotInfo.Slot); } } }
/// <summary> /// Finds slots based on the client and confirms it. /// </summary> /// <param name="sender">Client who requested to confirm his slot.</param> /// <returns>Slot id which client confirmed or null if failed.</returns> public Int32?ConfirmSlot(ConnectedClient sender) { lock (this.slotsSyncLock) { SlotInfo slotInfo = this.slots.Find(slot => slot.Client == sender); if (slotInfo == null) { // Specific situation which should not occur. No slot info found for specified client. return(null); } else { slotInfo.ConfirmSlot(); return(slotInfo.Slot); } } }