/// <summary> /// Handles the configuration. /// </summary> private static void HandleConfiguration() { _config = new ConfigurationHandler(_dependencyUtility, "configuration.json"); _dependencyUtility.Register <JsonSerializerSettings>(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); _dependencyUtility.Register <IConfigurationHandler>(_config); }
/// <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()); }