/// <summary> /// Initializes a new instance of the <see cref="ServerBase{T, TServerClient}" /> class. /// </summary> /// <param name="listenerCount"> (Optional) The listener count. </param> private protected ServerBase(byte listenerCount = 1) { _listenerCount = listenerCount; _dataReceivedCallbacks = new Dictionary <uint, ServerClientEventEntry <TServerClient> >(INITIAL_QUEUE_SIZE); _clients = new Dictionary <T, TServerClient>(INITIAL_CLIENT_QUEUE_SIZE); _clientsLock = new SpinLock(Debugger.IsAttached); _dataReceivedCallbacksLock = new SpinLock(Debugger.IsAttached); _packetID = 1; _clientDataReceived = new Event <ClientCommandDataReceivedHandler <TServerClient> >(); _bigDataHandler = new BigDataHandler(); }
/// <summary> /// Initializes a new instance of the <see cref="ClientBase" /> class. /// </summary> /// <param name="listenerCount"> (Optional) The listener count. </param> private protected ClientBase(byte listenerCount = 1) { _listenerCount = listenerCount; _clientSocket = null; _dataReceivedCallbacks = new Dictionary <uint, ClientEventEntry>(INITIAL_QUEUE_SIZE); _taskCompletionSources = new Dictionary <uint, TaskCompletionSource <Packet> >(INITIAL_TASK_COMPLETION_QUEUE_SIZE); _lockTaskCompletionSources = new SpinLock(Debugger.IsAttached); _dataReceivedCallbacksLock = new SpinLock(Debugger.IsAttached); _dataReceived = new Event <CommandDataReceivedHandler>(); _responseID = 1; _bigDataHandler = new BigDataHandler(); Random rnd = new Random((int)DateTime.UtcNow.Ticks); rnd.NextBytes(_connectChecksum); _manuelResetEvent = new ManualResetEvent(false); }