Exemple #1
0
        protected override void OnStop()
        {
            Thread oldThread;

            lock (serverThreadLock)
            {
                oldThread    = serverThread;
                serverThread = null;
            }

            if (oldThread != null)
            {
                runner.Stop("Stopping the service");

                if (oldThread != System.Threading.Thread.CurrentThread)
                {
                    RequestAdditionalTime(Guncho.Properties.Settings.Default.EventGranularity * 2);
                    oldThread.Join();
                }
            }
        }
Exemple #2
0
        public void TestGetPlayerShouldNotBeNull()
        {
            var server = new ServerRunner();

            server.Start();
            var client = new ClientRunner("127.0.0.1", 32123);

            client.Start();
            client.JoinServer("player");
            server.GetPlayer("player").Should().NotBeNull();
            server.Stop();
        }
Exemple #3
0
        public void TestLeavePlayer()
        {
            var server = new ServerRunner();

            server.Start();
            var client = new ClientRunner("127.0.0.1", 32123);

            client.Start();
            client.JoinServer("player");
            Thread.Sleep(1000);
            var player = server.GetPlayer("player");

            server.LeavePlayer(server.GetPlayerInfo(player.Pseudo)).Should().Be(true);
            server.Stop();
        }
Exemple #4
0
        public void TestGetPlayerPosition()
        {
            var server = new ServerRunner();

            server.Start();
            var client = new ClientRunner("127.0.0.1", 32123);

            client.Start();
            client.JoinServer("player");
            Thread.Sleep(1000);
            var player = server.GetPlayer("player");

            Thread.Sleep(1000);
            server.Invoking(o => o.GetPlayerPosition(player)).ShouldNotThrow <NullReferenceException>();
            server.Stop();
        }