Example #1
0
        static void Main(string[] args)
        {
            IPEndPoint endPoint = NetUtils.CreateEndPoint(
                EndPointConfig.HOST,
                EndPointConfig.PORT
                );

            GameClientSpec spec = new GameClientSpec
            {
                bufferSize = 100,
                endPoint   = endPoint
            };

            GameClient gameClient = new GameClient(spec, new DefaultRemoteRequestMapper())
            {
                OnDisconnect = () => Console.WriteLine("I'm disconnecting :/")
            };

            gameClient.Start(
                () => Console.WriteLine("Uspesno povezan"),
                () => Console.WriteLine("Nije uspesno povezan")
                );

            gameClient.Send(new LoginRequest
            {
                Username = "******",
                Password = "******"
            });

            gameClient.Send(new CardListRequest());

            gameClient.Send(new QueueEntryRequest {
                Deck = new int[] { 0, 0, 0, 0 }
            });

            gameClient.Send(new QueueExitRequest());

            gameClient.Send(new QueueEntryRequest
            {
                Deck = new int[] { 0, 0, 0, 0 }
            });
            gameClient.Send(new QueueEntryRequest
            {
                Deck = new int[] { 0, 0, 0, 0 }
            });

            gameClient.Send(new QueueExitRequest());
            gameClient.Send(new QueueExitRequest());

            Console.WriteLine("Press any key to terminate game client...");
            Console.ReadKey();

            gameClient.Disconnect();

            Console.ReadKey();
        }
    private void InitializeGameClient()
    {
        IPEndPoint     endPoint = NetUtils.CreateEndPoint(networkSettings.host, networkSettings.port);
        GameClientSpec spec     = new GameClientSpec
        {
            endPoint   = endPoint,
            bufferSize = networkSettings.bufferSize
        };

        m_globalReference.GameClient = new GameClient(spec);

        m_globalReference.GameClient.OnDisconnect = () =>
                                                    m_globalReference.ExecutionQueue.Add(() => m_globalReference.SceneController.LoadScene("DisconnectedScene"));
    }