Start() private method

private Start ( ) : void
return void
Esempio n. 1
0
 /// <summary>
 /// Démarre le client, le connecte et met à jour les propriétés initiales
 /// </summary>
 public void Start()
 {
     MapSeed = 0;
     GameClient.Start();
     IsRunning = true;
     GameClient.Connect(HostIP, Port);
     //System.Diagnostics.Debug.WriteLine("Client connecté à " + HostIP + ":" + Port);
 }
Esempio n. 2
0
        public void StartWithHost()
        {
            var host = "10.10.10.10";

            GameClient.Start(unityServer, new[] { "-host", host });
            unityServer.Received(1).StartClient();
            unityServer.Received(1).SetHost(host);
            unityServer.Received(1).SetPort(7777);
        }
Esempio n. 3
0
        public void StartWithPort()
        {
            var args = new[] { "-port", "8080" };

            GameClient.Start(unityServer, args);
            unityServer.Received(1).StartClient();
            unityServer.Received(1).SetHost("localhost");
            unityServer.Received(1).SetPort(8080);
        }
Esempio n. 4
0
        public void StartWithHostAndPort()
        {
            var host = "10.10.10.10";
            var args = new[] { "-host", host, "-port", "8080" };

            GameClient.Start(unityServer, args);
            unityServer.Received(1).StartClient();
            unityServer.Received(1).SetHost(host);
            unityServer.Received(1).SetPort(8080);
        }
Esempio n. 5
0
 private void StartDuel()
 {
     if (m_gameClients.Count <= MaxGames)
     {
         GameClient game = new GameClient(this, m_server);
         game.Start();
         AddGameClient(game);
         Logger.WriteLine("Checkmate game created.");
     }
 }
Esempio n. 6
0
        private void OnStartDuel(string data)
        {
            DuelRequest duel   = JsonConvert.DeserializeObject <DuelRequest>(data);
            ServerInfo  server = Client.GetServer(duel.Server);

            if (server != null)
            {
                Logger.WriteLine("Duel requested. Room informations are " + duel.DuelFormatString + ".");
                GameClient game = new GameClient(Client, server, duel.DuelFormatString);
                game.Start();
                Client.AddGameClient(game);
            }
        }
Esempio n. 7
0
        private static void Run(object o)
        {
#if !DEBUG
            try
            {
#endif
            WindBotInfo Info  = (WindBotInfo)o;
            GameClient client = new GameClient(Info);
            client.Start();
            Logger.DebugWriteLine(client.Username + " started.");
            while (client.Connection.IsConnected)
            {
#if !DEBUG
                try
                {
#endif
                client.Tick();
                Thread.Sleep(30);
#if !DEBUG
            }
            catch (Exception ex)
            {
                if (!DebugMode)
                {
                    Logger.WriteErrorLine("Tick Error: " + ex);
                }
                else
                {
                    throw ex;
                }
            }
#endif
            }
            Logger.DebugWriteLine(client.Username + " end.");
#if !DEBUG
        }

        catch (Exception ex)
        {
            if (!DebugMode)
            {
                Logger.WriteErrorLine("Run Error: " + ex);
            }
            else
            {
                throw ex;
            }
        }
#endif
        }
Esempio n. 8
0
        private static GameClient CreateClient()
        {
            //1 创建客户端
            GameClient client = new GameClient(new StringSerializer());
            //string ip = "192.168.1.5";
            //string ip = "139.196.21.206";
            string ip = "127.0.0.1";

            //注册接收
            client.Register <String>();
            client.MessageReceived += Client_MessageReceived;
            //启动
            client.Start(ip, 15000);
            return(client);
        }
Esempio n. 9
0
        private static void Run(String username, String deck, String serverIP, int serverPort, String room)
        {
            Rand = new Random();
            CardsManager.Init();
            DecksManager.Init();

            // Start two clients and connect them to the same room. Which deck is gonna win?
            GameClient clientA = new GameClient(username, deck, serverIP, serverPort, room);

            clientA.Start();
            while (clientA.Connection.IsConnected)
            {
                clientA.Tick();
                Thread.Sleep(1);
            }
        }
Esempio n. 10
0
        private static void Run()
        {
            Init("cards.cdb");

            // Start two clients and connect them to the same server. Which deck is gonna win?
            GameClient clientA = new GameClient("Wind", "Horus", "127.0.0.1", 7911);
            GameClient clientB = new GameClient("Fire", "OldSchool", "127.0.0.1", 7911);

            clientA.Start();
            clientB.Start();
            while (clientA.Connection.IsConnected || clientB.Connection.IsConnected)
            {
                clientA.Tick();
                clientB.Tick();
                Thread.Sleep(1);
            }
        }
Esempio n. 11
0
        private static void Run(object o)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
#if !DEBUG
            try
            {
                //all errors will be catched instead of causing the program to crash.
#endif
            WindBotInfo Info  = (WindBotInfo)o;
            GameClient client = new GameClient(Info);
            client.Start();
            Logger.DebugWriteLine(client.Username + " started.");
            while (client.Connection.IsConnected)
            {
#if !DEBUG
                try
                {
#endif
                client.Tick();
                Thread.Sleep(30);
#if !DEBUG
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLine("Tick Error: " + ex);
                client.Chat("I crashed, check the crash.log file in the WindBot folder", true);
                using (StreamWriter sw = File.AppendText(Path.Combine(Program.AssetPath, "crash.log")))
                {
                    sw.WriteLine("[" + DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "] Tick Error: " + ex);
                }
                client.Connection.Close();
                return;
            }
#endif
            }
            Logger.DebugWriteLine(client.Username + " end.");
#if !DEBUG
        }

        catch (Exception ex)
        {
            Logger.WriteErrorLine("Run Error: " + ex);
        }
#endif
        }
 private void ConnectionAttempt(GameClient gameClient, int currentTry, int maxTries)
 {
     if (currentTry >= maxTries)
     {
         HandleFailedConnecting();
         return;
     }
     infoText.text = "Povezivanje na server" + new String('.', currentTry % 3 + 1);
     gameClient.Start(
         () => {
         slider.Percent = .5f;
         ExecuteAfterDelay(() => CardListLoading(gameClient), .5f);
     },
         () => {
         ExecuteAfterDelay(() => ConnectionAttempt(gameClient, currentTry + 1, maxTries), .2f);
     }
         );
 }
Esempio n. 13
0
        private static GameClient CreateClient()
        {
            //1 创建客户端
            GameClient client = new GameClient(new VerintHeadPackager(), new ProtoBufSerializer(new GameConfig()
            {
                DESKey = "421w6tW1ivg=",
                Secret = "whoareyou?"
            }, new ConsoleLogger("A", (s, level) => true, true)));
            //string ip = "192.168.1.5";
            string ip = "139.196.21.206";

            //string ip = "101.132.118.172";

            //注册接收
            client.Register <String>();
            client.MessageReceived += Client_MessageReceived;
            //启动
            client.Start(ip, 6003);
            return(client);
        }
Esempio n. 14
0
    void Start()
    {
        // In order to test and process messages we need these options.
        // However you can remove them if They do not suit your design.
        Application.runInBackground = true;
        Input.multiTouchEnabled     = false;

        // Singleton implementation
        if (Instance == null)
        {
            Instance = this;
        }

        StartNLog();

        gameObject.AddComponent <OnGuiDebugger>();

        #region DEBUG

        ResetButton.onClick.AddListener(ResetButtonHandler);
        IbsButton.onClick.AddListener(IbsButtonHandler);
        DbsButton.onClick.AddListener(DbsButtonHandler);

        AplButton.onClick.AddListener(AplButtonHandler);
        DplButton.onClick.AddListener(DplButtonHandler);
        AdlButton.onClick.AddListener(AdButtonHandler);
        DdlButton.onClick.AddListener(DdButtonHandler);
        PauseButton.onClick.AddListener(PauseButtonHandler);

        #endregion

        ECSManager.Instance.Start();

        new Thread(() =>
        {
            _client = GameClient.Instance;
            _client.SetCallback(a => _messageConsumer.AddMessage(a));
            yojimbo.printf(yojimbo.LOG_LEVEL_INFO, "Connecting client");
            _client.Start();
        }).Start();
    }
Esempio n. 15
0
        private static void Run(object o)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
#if !DEBUG
            try
            {
                //all errors will be catched instead of causing the program to crash.
#endif
            WindBotInfo Info  = (WindBotInfo)o;
            GameClient client = new GameClient(Info);
            client.Start();
            Logger.DebugWriteLine(client.Username + " started.");
            while (client.Connection.IsConnected)
            {
#if !DEBUG
                try
                {
#endif
                client.Tick();
                Thread.Sleep(30);
#if !DEBUG
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLine("Tick Error: " + ex);
            }
#endif
            }
            Logger.DebugWriteLine(client.Username + " end.");
#if !DEBUG
        }

        catch (Exception ex)
        {
            Logger.WriteErrorLine("Run Error: " + ex);
        }
#endif
        }
Esempio n. 16
0
    public void GameClientCanCreateANewGame()
    {
        // Dummy database.
        var databasesGameObject = new GameObject("Databases");

        Databases.Instance = databasesGameObject.AddComponent <Databases>();

        Databases.Instance.RecipeDefinitions     = new Simulation.Data.RecipeDefinition[0];
        Databases.Instance.TechnologyDefinitions = new Simulation.Data.TechnologyDefinition[0];

        using (GameServer server = new GameServer(System.Net.IPAddress.Parse("127.0.0.1"), 8052, TimeSpan.FromSeconds(30)))
        {
            server.Start();
            Thread.Sleep(50);

            Assert.AreEqual(0, server.GameCount);
            using (GameClient client = new GameClient("localhost", 8052))
            {
                client.Start();

                Assert.AreEqual(0, server.GameCount);

                try
                {
                    var createGameTask = AsyncHelpers.RunSync <byte>(() => client.PostCreateGameOrder(1));
                    AsyncHelpers.RunSync(() => client.PostJoinGameOrder(createGameTask));
                }
                catch (System.Exception exception)
                {
                    Assert.Fail(exception.Message);
                }

                Assert.AreEqual(1, server.GameCount);
                Assert.NotNull(client.Game);
            }
        }
    }
Esempio n. 17
0
        static void Main(string[] args)
        {
            IClientConfig   clientConfig   = new DefaultClientConfig();
            ILogger         logger         = new ConsoleLogger();
            IJsonSerializer jsonSerializer = new MyJsonSerializer();

            logger.Info("Hello, press any key to start the game client console.");

            System.Console.ReadKey(intercept: true);

            var gameClient = new GameClient(logger, jsonSerializer, clientConfig);

            gameClient.Start("http://localhost:8110");
            var runner = new SimulationRunner(logger, gameClient, clientConfig.Simulation.FixedTick);

            runner.Start();

            logger.Info("Game client running...");

            System.Console.ReadKey(intercept: true);

            runner.Stop();
            gameClient.Stop();
        }
Esempio n. 18
0
 public void Start()
 {
     GameClient.Start(unityServer, new string[0]);
     unityServer.Received(1).StartClient();
     Assert.Throws <Exception>(() => GameClient.Start(unityServer, new string[0]));
 }