/// <summary> /// Initializes a new instance of the <see cref="WebSocketServer"/> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="host">The host.</param> /// <param name="port">The port.</param> /// <param name="dependencyUtility">The dependency utility.</param> /// <param name="listenerThreads">The listener threads.</param> /// <param name="clientThreadMultiplier">The client thread multiplier.</param> public WebSocketServer(string id, string host, int port, IDependencyUtility dependencyUtility = null, int listenerThreads = 1, int clientThreadMultiplier = 3) { Id = id; Host = host; Port = port; _listenerThreads = listenerThreads; _clientThreadMultiplier = clientThreadMultiplier; _dependencyUtility = dependencyUtility ?? new DependencyUtility(); _logger = _dependencyUtility.Resolve <ILogger>() ?? _dependencyUtility.Register <ILogger>(new Logger()); _securityContainer = _dependencyUtility.Resolve <ISecurityContainer>() ?? _dependencyUtility.Register <ISecurityContainer>(new SecurityContainer(null, SslProtocols.None, false, false, false)); _clientHandler = _dependencyUtility.Resolve <ITcpHandler>() ?? _dependencyUtility.Register <ITcpHandler>(new TcpHandler(IPAddress.Parse(Host), Port)); _connectionManager = _dependencyUtility.Resolve <IWebSocketConnectionManager>() ?? _dependencyUtility.Register <IWebSocketConnectionManager>(new WebSocketConnectionManager(_dependencyUtility)); _threadHelper = _dependencyUtility.Resolve <IThreadHelper>() ?? _dependencyUtility.Register <IThreadHelper>(new ThreadHelper()); _routeTable = _dependencyUtility.Resolve <IRouteTable>() ?? _dependencyUtility.Register <IRouteTable>(BuildRouteTable()); }
/* * The Code that should be realized via Thread. * In my case the client connection and Request and Response Handling */ private static void ReceiveClient(ITcpHandler tcpHandler) { ClientHandler clientHandler = new ClientHandler(tcpHandler); clientHandler.ExecuteRequest(); clientHandler.CloseClient(); ConcurrentConnections.Release(); }
internal TcpClientInfo(ITcpHandler parent, TcpClient client, HandlerType type, int timeout, int buffersize) { Parent = parent; Client = client; HndlType = type; Timeout = timeout; BufferSize = buffersize; WriteSync = new ThreadSafeHelper <int>(); }
public ClientHandler(ITcpHandler tcpHandler) { TcpHandler = tcpHandler; TcpHandler.AcceptTcpClient(); }