示例#1
0
        public void Server_DestroyServer(string reason)
        {
            GameNetworkServer server = GameNetworkServer.Instance;

            if (server != null)
            {
                server.Dispose(reason);

                SuspendWorkingWhenApplicationIsNotActive = true;
            }
        }
示例#2
0
        private void CreateServer_Click(Button sender)
        {
            //if (string.IsNullOrEmpty(serverUserName))
            if (string.IsNullOrEmpty(Program.username))
            {
                SetInfo("Invalid user name.", true);
                return;
            }

            SetInfo("Creating server...", false);

            GameNetworkServer server = new GameNetworkServer(createServerName.ToString(),
                                                             EngineVersionInformation.Version, 128, true);

            //int port = 229;

            string error;

            if (!server.BeginListen(createserverport, out error))
            {
                SetInfo("Server Listen Error: " + error, true);
                server.Dispose("");
                return;
            }

            //create user for server
            server.UserManagementService.CreateServerUser(Program.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();
        }
示例#3
0
        void CreateServer_Click(Button sender)
        {
            if (string.IsNullOrEmpty(userName))
            {
                SetInfo("Invalid user name.", true);
                return;
            }

            SetInfo("Creating server...", false);

            GameNetworkServer server = new GameNetworkServer("NeoAxis Server",
                                                             EngineVersionInformation.Version, 128, true);

            int port = 56565;

            string error;

            if (!server.BeginListen(port, out error))
            {
                SetInfo("Error: " + error, true);
                server.Dispose("");
                return;
            }

            //create user for server
            server.UserManagementService.CreateServerUser(userName);

            //close this window
            SetShouldDetach();

            //create lobby window
            MultiplayerLobbyWindow lobbyWindow = new MultiplayerLobbyWindow();

            GameEngineApp.Instance.ControlManager.Controls.Add(lobbyWindow);

            GameEngineApp.Instance.Server_OnCreateServer();
        }