// public GameNetworkServer( string serverName, string serverVersion, int maxConnections, bool entitySystemServiceEnabled) : base(serverName, serverVersion, maxConnections) { if (instance != null) Log.Fatal("GameNetworkServer.GameNetworkServer: instance != null."); instance = this; //register network services //register user management service userManagementService = new UserManagementServerNetworkService(); RegisterService(userManagementService); //register custom messages service customMessagesService = new CustomMessagesServerNetworkService(); RegisterService(customMessagesService); //register chat service chatService = new ChatServerNetworkService(userManagementService); RegisterService(chatService); //register entity system service if (entitySystemServiceEnabled) { entitySystemService = new EntitySystemServerNetworkService(userManagementService); RegisterService(entitySystemService); } }
private void Create() { if (GameNetworkServer.Instance != null) { Log("Error: Already created"); return; } GameNetworkServer server = new GameNetworkServer("Assault Knights Chat Server", EngineVersionInformation.Version, 128, true); server.UserManagementService.AddUserEvent += UserManagementService_AddUserEvent; server.UserManagementService.RemoveUserEvent += UserManagementService_RemoveUserEvent; server.ChatService.ReceiveText += ChatService_ReceiveText; //server.EntitySystemService. int port = 56565; string error; if (!server.BeginListen(port, out error)) { Log("Error: " + error); Destroy(); return; } Log("Server has been created"); Log("Listening port {0}...", port); buttonCreate.Enabled = false; buttonDestroy.Enabled = true; }
// public GameNetworkServer(string serverName, string serverVersion, int maxConnections, bool entitySystemServiceEnabled) : base(serverName, serverVersion, maxConnections) { if (instance != null) { Log.Fatal("GameNetworkServer.GameNetworkServer: instance != null."); } instance = this; //register network services //register user management service userManagementService = new UserManagementServerNetworkService(); RegisterService(userManagementService); //register custom messages service customMessagesService = new CustomMessagesServerNetworkService(); RegisterService(customMessagesService); //register chat service chatService = new ChatServerNetworkService(userManagementService); RegisterService(chatService); //register entity system service if (entitySystemServiceEnabled) { entitySystemService = new EntitySystemServerNetworkService(userManagementService); RegisterService(entitySystemService); } }
void Create() { if( GameNetworkServer.Instance != null ) { Log( "Error: Server already created" ); return; } //public GameNetworkServer(string serverName, string serverVersion, int maxConnections, string serverPassword, //bool entitySystemServiceEnabled) //: base(serverName, serverVersion, maxConnections) GameNetworkServer server = new GameNetworkServer( "NeoAxis Game Server", EngineVersionInformation.Version, 128, true ); server.UserManagementService.AddUserEvent += UserManagementService_AddUserEvent; server.UserManagementService.RemoveUserEvent += UserManagementService_RemoveUserEvent; server.ChatService.ReceiveText += ChatService_ReceiveText; server.CustomMessagesService.ReceiveMessage += CustomMessagesService_ReceiveMessage; int port = 56565; string error; if( !server.BeginListen( port, out error ) ) { Log( "Error: " + error ); Destroy(); return; } Log( "Server has been created" ); Log( "Listening port {0}...", port ); buttonCreate.Enabled = false; buttonDestroy.Enabled = true; buttonMapLoad.Enabled = true; }
public override void Dispose(string reason) { base.Dispose(reason); instance = null; }
private void CreateServer_Click(Button sender) { if (string.IsNullOrEmpty(userName)) { SetInfo("Invalid user name.", true); return; } SetInfo("Creating server...", false); GameNetworkServer server = new GameNetworkServer("Assault Knights Server", EngineVersionInformation.Version, 128, "", true); int port = 65533; string error; if (!server.BeginListen(port, out error)) { SetInfo("Error: " + error, true); server.Dispose(""); return; } //create user for server server.UserManagementService.CreateServerUser(userName); //close all windows foreach (Control control in GameEngineApp.Instance.ControlManager.Controls) control.SetShouldDetach(); //create lobby window MultiplayerLobbyWindow lobbyWindow = new MultiplayerLobbyWindow(); GameEngineApp.Instance.ControlManager.Controls.Add(lobbyWindow); GameEngineApp.Instance.Server_OnCreateServer(); }
private void Create() { if (GameNetworkServer.Instance != null) { Log("Error: Server already created"); return; } if (serverName == "" || serverName == null) { Log("Set Server Name first, then we can add your server"); return; } else { serverName = textServerName.Text.ToString(); } if (PortTextBox.Text == "" || PortTextBox.Text == null) { Log("Invalid server port set, please set 1 to 65535"); return; } else { port = int.Parse(PortTextBox.Text); } GameNetworkServer server = new GameNetworkServer(serverName, EngineVersionInformation.Version, 128, serverPassword, true); server.UserManagementService.AddUserEvent += UserManagementService_AddUserEvent; server.UserManagementService.RemoveUserEvent += UserManagementService_RemoveUserEvent; server.ChatService.ReceiveText += ChatService_ReceiveText; server.CustomMessagesService.ReceiveMessage += CustomMessagesService_ReceiveMessage; // server.CustomMessagesService.ReceiveMessage += SpawnInfo; string error; if (!server.BeginListen(port, out error)) { Log("Error: " + error); Destroy(); servercreated = false; maploaded = false; return; } else { servercreated = true; } //load map at startup if (comboBoxMaps.SelectedItem != null) { //Create(); string mapName = comboBoxMaps.SelectedItem as string; if (!MapLoad(mapName)) return; mapname = mapName; //if (makePrivate == false) //{ // Log("Server has been made public."); //} //else //{ // Log("Server has been set private."); //} SqlAdd(); if (Program.AKsqlcon.State.ToString() == "Open") { SQLCon.Text = "Connection Active"; ; SQLCon.BackColor = Color.LightGreen; } else { SQLCon.Text = "Connection Lost"; ; SQLCon.BackColor = Color.Red; } } Log("Server has been created"); Log("Listening port {0}...", port); buttonCreate.Enabled = false; buttonDestroy.Enabled = true; buttonMapLoad.Enabled = true; checkPrivateServer.Enabled = false; ntbMapTime.Enabled = false; }