Example #1
0
        public void Start()
        {
            if (serverConnection == null)
            {
                throw new StartupException(Startup.StartupExceptions.NoServerConnection, "No server connection type has been initialized");
            }

            var port = ConfigurationManager.GetInt(ServerConfigConstants.SERVER_PORT);

            if (port <= 0 || port >= 65535)
            {
                throw new StartupException(Startup.StartupExceptions.InvalidPortNumber, "Server port with number '{0}' is invalid", port);
            }

            serverConnection.OnClientConnected += serverConnection_OnClientConnected;
            serverConnection.AcceptConnections(port);

            Logger.Info("Server", "Start", "Server accepting connections on port {0}", port);
        }