Exemplo n.º 1
0
        public void Enter()
        {
            // first we connect to the gameserver
            var socket = new Socket(SocketType.Stream, ProtocolType.IP);

            socket.Connect(StartClient.IP, StartClient.Port);
            Adapter = new KettleAdapter(new NetworkStream(socket));
            Adapter.OnGameJoined     += OnGameJoined;
            Adapter.OnEntityChoices  += OnEntityChoices;
            Adapter.OnEntitiesChosen += OnEntitiesChosen;
            Adapter.OnOptionsBlock   += OnOptionsBlock;
            Adapter.OnUserUI         += OnUserUI;
            Adapter.OnHistory        += OnHistory;

            Adapter.SendMessage(StartClient.JoinGame);

            // and then we keep listening on the socket
            while (true)
            {
                if (!Adapter.HandleNextPacket())
                {
                    Console.WriteLine("Kettle session ended.");
                    return;
                }
            }
        }
        public void Enter()
        {
            // We wait until someone connects to this server

            while (true)
            {
                Socket        gameserver  = Listener.Accept();
                KettleAdapter gameadapter = new KettleAdapter(new NetworkStream(gameserver));
                gameadapter.OnStartClient += OnStartClient;

                try
                {
                    while (true)
                    {
                        if (!gameadapter.HandleNextPacket())
                        {
                            Console.WriteLine("Kettle AI server ended.");
                            break;
                        }
                    }
                }
                catch (IOException)
                {
                    Console.WriteLine("Connection closed");
                }
            }
        }
Exemplo n.º 3
0
 public void Enter()
 {
     while (true)
     {
         if (!Adapter.HandleNextPacket())
         {
             Console.WriteLine("Kettle session ended.");
             return;
         }
     }
 }
Exemplo n.º 4
0
 public void Enter()
 {
     while (true)
     {
         Console.WriteLine("Handling next packet..");
         if (!Adapter.HandleNextPacket())
         {
             Console.WriteLine("Kettle session ended.");
             return;
         }
         Console.WriteLine("Done!");
     }
 }