//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(); }
private void ClientListener() { UdpTcpPair.StartListener(); try { while (true) { Player clientobj = new Player(); this.AddClient(clientobj); } } catch (Exception) { /*Just let the listener thread end*/ } }
public override GameObjectUpdate GetUDPMessage(UdpTcpPair client) { return(new GameObjectUpdate(client)); }
public override ControlStateUpdate GetUDPMessage(UdpTcpPair client) { return(new ControlStateUpdate(client)); }
public GameObjectUpdate(UdpTcpPair pair) : base(pair) { }
public ControlStateUpdate(UdpTcpPair pair) : base(pair) { }