Esempio n. 1
0
        public OnPoolServer()
        {
            var threadManager = LocalThreadManager.Start();

            Task.Run(() => {
                while (true)
                {
                    Thread.Sleep(1000);
                    Console.WriteLine($"Messages Per Second: {SocketManager.Counter} Open Pools: {pools.Count} Connected Clients: {clients.Count}");
                    SocketManager.Counter = 0;
                }
            });


            serverManager = new ClientListener(socket =>
            {
                var socketManager           = new SocketManager(socket);
                socketManager.onReceive    += onMessage;
                socketManager.OnDisconnect += RemoveClient;
                AddClient(socketManager);
                socketManager.Start();
            }
                                               );
            serverManager.StartServer();
            threadManager.Process();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            LocalThreadManager.Start().Process();

            var uri = new Uri("http://localhost:" + args[0]);
            HostConfiguration hostConfigs = new HostConfiguration();

            hostConfigs.UrlReservations.CreateAutomatically = true;

            Stopwatch sw = new Stopwatch();

            sw.Start();
            timer = new Timer((s) =>
            {
                Console.WriteLine($"{BaseBootstrapper.start} Started - {BaseBootstrapper.finish} Finished   Diff: {BaseBootstrapper.finish - BaseBootstrapper.start}");
                BaseBootstrapper.start  = 0;
                BaseBootstrapper.finish = 0;
                sw.Restart();
            }, null, 1000, 1000);

            using (var host = new NancyHost(uri, new BaseBootstrapper(), hostConfigs))
            {
                host.Start();

                Console.WriteLine("Your application is running on " + uri);
                Console.WriteLine("Press any [Enter] to close the host.");
                Console.ReadLine();
            }
        }
Esempio n. 3
0
        public static void Main()
        {
//            startNewGame();
//            return;
            LocalThreadManager.Start().Process();
            MongoServerLog.AddServerLog("Master.Start", "1", "1");
            var logic = MasterVoteServerLogic.GetServerLogic();

            while (true)
            {
                Console.WriteLine("Press enter to die");
                Console.ReadLine();
                logic.gameTick(null);
            }
        }
Esempio n. 4
0
        public static async Task RunTests()
        {
            try {
                var tc = new Tests();

                var tests = new List <Action <Action> >();

                for (int i = 0; i < 10; i++)
                {
                    tests.AddRange(new Action <Action>[]
                    {
//                        tc.TestEveryone,
//                        tc.Test100ClientsAll,
                        tc.TestFastestPool,
                        tc.TestLeavePool,
                        tc.TestOnPoolUpdatedResponse,
                        tc.TestOnPoolDisconnectedResponse,
                        tc.TestClientResponse,
                        tc.TestPoolResponse,
                        tc.TestDirectClientResponse,
                        tc.TestAllPoolResponse,
                        tc.TestClientSendObject,
                        tc.TestPoolToClient
                    });
                }
                tests.Add(tc.TestSlammer);

                while (true)
                {
                    foreach (var test in tests)
                    {
                        var threadManager = LocalThreadManager.Start();
                        test(() => {
                            threadManager.Kill();
                        });
                        await threadManager.Process();

                        tc.CleanupTest();
                        Console.WriteLine("Test Pass");
                    }
                }
            }
            catch (Exception ex) {
                Console.WriteLine(ex);
            }
            Console.WriteLine("Done");
        }