Example #1
0
        private async Task KickOffNewSocketAsync(TcpContext <TSocketData> tcpContext, TcpClient acceptedSocket)
        {
            var bufferToSend = SocketMemoryUtils.AllocateByteArray(_sendBufferSize);

            await tcpContext.StartAsync(acceptedSocket, _getSerializer(), _lockObject, _log,
                                        socket => { _connections.RemoveSocket(socket.Id); }, bufferToSend);

            _log.InvokeInfoLog(tcpContext,
                               $"Socket Accepted; Ip:{acceptedSocket.Client.RemoteEndPoint}. Id=" + tcpContext.Id);

            tcpContext.StartReadThread(_readBufferSize);
        }
Example #2
0
 public void AddSocket(TcpContext <T> connection)
 {
     _lockSlim.EnterWriteLock();
     try
     {
         _sockets.Add(connection.Id, connection);
         _socketsAsList = _sockets.Values.ToList();
     }
     finally
     {
         _lockSlim.ExitWriteLock();
     }
 }