Inheritance: NetworkServer
        void Create()
        {
            if( GameNetworkServer.Instance != null )
            {
                Log( "Error: Already created" );
                return;
            }

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

            server.UserManagementService.AddUserEvent += UserManagementService_AddUserEvent;
            server.UserManagementService.RemoveUserEvent += UserManagementService_RemoveUserEvent;
            server.ChatService.ReceiveText += ChatService_ReceiveText;

            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;
        }
Example #2
0
        //

        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);
            }
        }
        //
        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 );
            }
        }
Example #4
0
            public override void OnUpdate()
            {
                StringBuilder text = new StringBuilder("");

                //GameNetworkServer
                GameNetworkServer server = GameNetworkServer.Instance;

                if (server != null)
                {
                    text.Append("Server:\n");
                    foreach (NetworkNode.ConnectedNode connectedNode in server.ConnectedNodes)
                    {
                        GetConnectedNodeData(connectedNode, text);
                    }
                    text.Append("\n");
                }

                //GameNetworkClient
                GameNetworkClient client = GameNetworkClient.Instance;

                if (client != null && client.Status == NetworkConnectionStatuses.Connected)
                {
                    text.Append("Client:\n");
                    GetConnectedNodeData(client.ServerConnectedNode, text);
                    text.Append("\n");
                }

                if (text.Length == 0)
                {
                    text.Append("No connections");
                }

                //EntitySystem statistics
                if (EntitySystemWorld.Instance != null)
                {
                    EntitySystemWorld.NetworkingInterface networkingInterface =
                        EntitySystemWorld.Instance._GetNetworkingInterface();
                    if (networkingInterface != null)
                    {
                        string[] lines = networkingInterface.GetStatisticsAsText();
                        foreach (string line in lines)
                        {
                            text.AppendFormat("-   {0}\n", line);
                        }
                    }
                }

                PageControl.Controls["Data"].Text = text.ToString();
            }
        public override void Dispose( string reason )
        {
            base.Dispose( reason );

            instance = null;
        }
        void CreateServer_Click( EButton 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 all windows
            foreach( EControl 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();
        }
Example #7
0
        public override void Dispose(string reason)
        {
            base.Dispose(reason);

            instance = null;
        }
Example #8
0
        void Create()
        {
            if( GameNetworkServer.Instance != null )
            {
                Log( "Error: Server already created" );
                return;
            }

            string mapName = comboBoxMaps.SelectedItem as string;
            if( string.IsNullOrEmpty( mapName ) )
            {
                Log( "Error: You should choose a start map" );
                return;
            }

            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;

            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;
            comboBoxMaps.Enabled = false;

            //load a map
            Log( "Loading map \"{0}\"...", mapName );
            MapLoad( mapName );
        }