public Game() { log = new Logger(); log.Info("Setting up game..."); trySetConnectDetails(); Window.Title = "Test Client"; Window.AllowUserResizing = false; graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; config = new NetPeerConfiguration(appName); config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse); client = new NetClient(config); // Start with an empty player manager. playerManager = new PlayerManager(); NetDebugComponent netDebugComponent = new NetDebugComponent(this, ref client); this.Components.Add(netDebugComponent); netDebugComponent.Visible = true; PlayerListDebugComponent playerListDebugComponent = new PlayerListDebugComponent(this, ref playerManager); this.Components.Add(playerListDebugComponent); playerListDebugComponent.Visible = true; }
public PlayerListDebugComponent(Game game, ref PlayerManager playerManager) : base(game) { this.playerManager = playerManager; this.game = game; this.position = new Vector2(5, 110); }
/// <summary> /// Creates, configures and starts the server. /// </summary> private static void setupServer() { log.Info("Setting up server..."); config = new NetPeerConfiguration(appName); config.Port = serverPort; // Clients will send a DiscoveryRequest to see if they can connect. config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest); // ConnectionApproval received once a client runs Connect(); must be explicitly approved or denied. config.EnableMessageType(NetIncomingMessageType.ConnectionApproval); playerManager = new PlayerManager(gameHeight, gameWidth); server = new NetServer(config); try { server.Start(); nextSendUpdates = NetTime.Now; Thread.Sleep(500); log.Info("Server started with status {0} on port {1}", server.Status, serverPort); } catch (Exception e) { log.Error("Failed to start server\n" + e); isShuttingDown = true; } }