Ejemplo n.º 1
0
        //SERVER//
        #region netServer stuff
        /// <summary>
        /// Initializes the MPServer if it is not already initialized and the MPClient is not initialized.
        /// </summary>
        public void ServerInitialize()
        {
            if (IsMPClientInitialized)
            {
                Log.Warning("Cannot initialize server. Client is already initialized.");
                return;
            }

            if (IsMPServerInitialized)
            {
                Log.Warning("Server is already initialized.");
                return;
            }

            Log.Message("Initialize server.");
            MPServer = new MPServer(StopProcessMessageThread);
            MPServer.serverLeavingProcessingMessageThread += MPServer_serverLeavingProcessingMessageThreadEvent;
            MPServer.unhandledMessageReceived             += MPServer_unhandledMessageReceivedEvent;
            MPServer.clientConnected                 += MPServer_clientConnectedEvent;
            MPServer.clientDisconnected              += MPServer_clientDisconnectedEvent;
            MPServer.allClientsDisconected           += MPServer_allClientsDissconectedEvent;
            MPServer.clientConnectionRequestApproved += MPServer_clientConnectionRequestApprovedEvent;
            MPServer.clientConnectionRequestDenied   += MPServer_clientConnectionRequestDeniedEvent;
            SetMPRole(MPRoleType.Server);
            Log.Message("Server initialized.");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Stops the netServer.
        /// </summary>
        public void ServerStop()
        {
            if (IsMPClientInitialized)
            {
                Log.Warning("Cannot stop the server. Client is initilalized");
                return;
            }
            if (!IsMPServerInitialized)
            {
                Log.Warning("Cannot stop the server. Server is not initialized.");
                return;
            }

            Log.Message("Stopping server.");
            MPServer.Stop();
            Log.Message("Server stopped.");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Starts the netServer.
        /// </summary>
        /// <param name="port">The port to listen on.</param>
        /// <param name="password">The password of the netServer.</param>
        /// <param name="maximumPlayerAmount">Maximum amount of players.</param>
        public void ServerStart(int port, string password, int maximumPlayerAmount)
        {
            if (IsMPClientInitialized)
            {
                Log.Warning("Cannot start the server. Client is initialized.");
                return;
            }

            if (!IsMPServerInitialized)
            {
                Log.Warning("Cannot start the server. The server is not initialized.");
                return;
            }

            Log.Message("Starting server.");
            MPServer.StartServer(port, password, maximumPlayerAmount);
            Log.Message("Server started.");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Starts the netServer.
        /// </summary>
        public void ServerStart()
        {
            if (IsMPClientInitialized)
            {
                Log.Warning("Cannot start the server. Client is initialized.");
                return;
            }

            if (!IsMPServerInitialized)
            {
                Log.Warning("Cannot start the server. The server is not initialized.");
                return;
            }

            Log.Message("Starting server.");
            MPServer.StartServer();
            SetMPRole(MPRoleType.Server);
            Log.Message("Server started.");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Uninitializes the MPServer. Sets it to null.
        /// </summary>
        public void ServerUninitialize()
        {
            if (!IsMPServerInitialized)
            {
                Log.Warning("Server is not initialized. Cannot uninitialize.");
                return;
            }

            Log.Message("Uninitialize server.");
            ServerStop();
            MPServer = null;
            SetMPRole(MPRoleType.None);
            Log.Message("Server uninitialized.");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes the MPServer if it is not already initialized and the MPClient is not initialized.
        /// </summary>
        public void ServerInitialize()
        {
            if (IsMPClientInitialized)
            {
                Log.Warning("Cannot initialize server. Client is already initialized.");
                return;
            }

            if (IsMPServerInitialized)
            {
                Log.Warning("Server is already initialized.");
                return;
            }

            Log.Message("Initialize server.");
            MPServer = new MPServer(StopProcessMessageThread);
            MPServer.serverLeavingProcessingMessageThread += MPServer_serverLeavingProcessingMessageThreadEvent;
            MPServer.unhandledMessageReceived += MPServer_unhandledMessageReceivedEvent;
            MPServer.clientConnected += MPServer_clientConnectedEvent;
            MPServer.clientDisconnected += MPServer_clientDisconnectedEvent;
            MPServer.allClientsDisconected += MPServer_allClientsDissconectedEvent;
            MPServer.clientConnectionRequestApproved += MPServer_clientConnectionRequestApprovedEvent;
            MPServer.clientConnectionRequestDenied += MPServer_clientConnectionRequestDeniedEvent;
            SetMPRole(MPRoleType.Server);
            Log.Message("Server initialized.");
        }