Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
		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;
		}
        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();
        }
Exemplo n.º 4
0
        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;
        }