예제 #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"));
    }
예제 #3
0
        public static void Main(string[] args)
        {
            Config.Prepare();

            Initializer.Initialize();

            var        handler  = new CardGameLogicRouter();
            IPEndPoint endPoint = NetUtils.CreateEndPoint(EndPointConfig.HOST, EndPointConfig.PORT);

            GameServerSpec gameServerSpec = new GameServerSpec
            {
                endPoint               = endPoint,
                eventConsumingAgents   = 10,
                maxServerConnections   = 50,
                socketServerBackLog    = 10,
                socketServerBufferSize = 50
            };

            var gameServer = new GameServer.GameServerLogic.GameServer(gameServerSpec, handler);

            Config.GameServer = gameServer;

            gameServer.Start();
        }