Example #1
0
        //This method starts running the lobby and blocks until the lobby ends
        public void Run()
        {
            //Start the client listener in its own thread
            //This thread allows clients to asynchronously join the lobby
            Thread clientListenerThread = new Thread(new ThreadStart(ClientListener));

            clientListenerThread.Start();

            //wait to start
            MessageBox.Show("Enter to start", NetUtils.GetLocalIP());

            //lock client list
            clientsMutex.WaitOne();
            clientsLocked = true;
            clientsMutex.ReleaseMutex();

            // Start up the game.
            Game1 game = new ServerGame(this);

            game.Run();

            //the game has finished
            foreach (Player c in clients)
            {
                c.Disconnect();
            }

            //this.prelimListener.Stop();
            UdpTcpPair.StopListener();
            clientListenerThread.Join();
        }
 public SetWorldSize(UdpTcpPair pair)
     : base(pair)
 {
     this.ResetReader();
     worldSize = this.ReadVector2();
     this.AssertMessageEnd();
 }
Example #3
0
 private void ClientListener()
 {
     UdpTcpPair.StartListener();
     try
     {
         while (true)
         {
             Player clientobj = new Player();
             this.AddClient(clientobj);
         }
     }
     catch (Exception) { /*Just let the listener thread end*/ }
 }
Example #4
0
 public override GameObjectUpdate GetUDPMessage(UdpTcpPair client)
 {
     return(new GameObjectUpdate(client));
 }
Example #5
0
 public override ControlStateUpdate GetUDPMessage(UdpTcpPair client)
 {
     return(new ControlStateUpdate(client));
 }
 public GameObjectUpdate(UdpTcpPair pair)
     : base(pair)
 {
 }
 public ControlStateUpdate(UdpTcpPair pair)
     : base(pair)
 {
 }