Example #1
0
        static void Main(string[] args)
        {
            ServerCommandLineOptions options = CommandLineParser.ParseArgs <ServerCommandLineOptions>(args, new ServerCommandLineOptions());

            CommunicationServerSettings settings = Configuration.FromFile <CommunicationServerSettings>(options.Conf);
            IConnectionEndpoint         endpoint = new ConnectionEndpoint(options.Port);

            CommunicationServer server = new CommunicationServer(endpoint, settings);

            server.Start();
        }
        public CommunicationServer(IConnectionEndpoint connectionEndpoint, CommunicationServerSettings settings)
        {
            this.ConnectionEndpoint = connectionEndpoint;
            RegisteredGames         = new GamesContainer();
            this.settings           = settings;

            connectionEndpoint.OnConnect        += OnClientConnect;
            connectionEndpoint.OnMessageRecieve += OnMessage;
            connectionEndpoint.OnDisconnected   += OnDisconnect;
            Clients      = new Dictionary <ulong, Socket>();
            freeIdList   = new List <ulong>();
            startedGames = new List <string>();
        }