Esempio n. 1
0
        void Client_ConnectionStatusChanged(NetworkClient sender, NetworkConnectionStatuses status)
        {
            switch (status)
            {
            case NetworkConnectionStatuses.Disconnected:
            {
                string text = "Unable to connect";
                if (sender.DisconnectionReason != "")
                {
                    text += ". " + sender.DisconnectionReason;
                }
                SetInfo(text, true);

                DisposeClient();
            }
            break;

            case NetworkConnectionStatuses.Connecting:
                SetInfo("Connecting...", false);
                break;

            case NetworkConnectionStatuses.Connected:
                SetInfo("Connected", false);

                //no work with client from this class anymore
                RemoveEventsForClient();
                notDisposeClientOnDetach = true;

                //close this window
                SetShouldDetach();

                //create lobby window
                MultiplayerLobbyWindow lobbyWindow = new MultiplayerLobbyWindow();
                GameEngineApp.Instance.ControlManager.Controls.Add(lobbyWindow);

                GameEngineApp.Instance.Client_OnConnectedToServer();

                break;
            }
        }
Esempio n. 2
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();
        }