Exemple #1
0
        private static TcpClientHandler event_clientCreated(SocketBinder binder, TcpServerHandler server, uint clientTimeout)
        {
            TcpClientHandler tmp_ = new TcpClientHandler(binder, server, clientTimeout);

            mainProgram.WriteLine("Client " + tmp_.Socket.ToString() + " has been created");
            return(tmp_);
        }
Exemple #2
0
        public static void Main()
        {
            //make the socketbinder
            SocketBinder binder = new SocketBinder();

            //make the console queue
            ConsoleQueue = new Queue <string>();
            InitConsoleFile();
            //make the settings
            settings = new SettingsSystem();
            //we need to load from the file, if there is one
            settings.ReadFile();
            //lets make the server too
            game_server = new TcpServerHandler(binder, settings.port, settings.maxConnections, settings.alignment, settings.timeout, settings.address);
            //start the server
            game_server.Start();
            //now lets set the methods for event stuff
            game_server.StartedEvent          += event_started;
            game_server.ClientCreatedEvent    += event_clientCreated;
            game_server.ClosedEvent           += event_closed;
            game_server.ReceivedEvent         += event_received;
            game_server.ConnectedEvent        += event_connected;
            game_server.DisconnectedEvent     += event_disconnected;
            game_server.AttemptReconnectEvent += event_attemptReconnect;
            game_server.ClientOverflowEvent   += event_clientOverflow;
            //now for the game world
            gameWorld = new GameWorld(game_server);

            //and now for the main game loop
            int sleepJump = 0,
                times     = 0;

            gameSteps = 0;
            //anything after here is not accessible until the server ends
            while (game_server.Status)
            {
                //commands
                CommandSystem.DoCommand(CommandSystem.Update());

                if (sleepJump == 2)
                {
                    sleepJump = 0;
                    event_step();
                    times++;
                    Thread.Sleep(16);
                }
                else
                {
                    sleepJump++;
                    event_step();
                    times++;
                    Thread.Sleep(17);
                }
                sleepJump++;
            }//whatever after the loop is triggered here when the server is closed
            UpdateConsoleFile();
            Thread.Sleep(1000);
        }
Exemple #3
0
 private static void event_closed(TcpServerHandler host)
 {
     if (host.ClientMap.Count > 0)
     {
         mainProgram.WriteLine("Closing the server with " + host.ClientMap.Count.ToString() + " clients");
     }
     else
     {
         mainProgram.WriteLine("Closing the server with no clients");
     }
 }
Exemple #4
0
 public GameWorld(TcpServerHandler _gameServer)
 {
     gameServer  = _gameServer;
     maxEntities = 32;
     maxObjects  = 64;
     entityMap   = new Dictionary <int, GameEntity>();
     clientMap   = new Dictionary <int, GameClient>(gameServer.MaxConnections);
     objectMap   = new Dictionary <int, GameObject>();
     createObject(new GamePoint3D(0d, 0d, -32d), new GamePoint3D(1024d, 1024d, 32d));
     createObject(new GamePoint3D(256d, 256d, 128d), new GamePoint3D(512d, 512d, 32d));
 }
		public void Start()
		{
			if (IsRunning)
				return;

            m_currUserIndex = 0;
			m_server = new TcpServerHandler(m_ip, m_port);
			//m_server.SSLServerCertificate = SslHelper.GetOrCreateSelfSignedCertificate("NameHere");
			m_server.Connected += m_server_Connected;
			m_server.Disconnected += m_server_Disconnected;
			m_server.ReceivedFull += m_server_ReceivedFull;
			m_server.Start();
		}
Exemple #6
0
        /// <summary>
        /// Start the Rcon server and begin to listen for connection
        /// </summary>
        public void Start()
        {
            if (IsRunning)
            {
                return;
            }

            m_server = new TcpServerHandler(m_ip, m_port);

            m_server.Connected    += m_server_Connected;
            m_server.Disconnected += m_server_Disconnected;
            m_server.ReceivedFull += m_server_ReceivedFull;
            m_server.Start();
        }
        public void Start()
        {
            if (IsRunning)
            {
                return;
            }

            m_currUserIndex = 0;
            m_server        = new TcpServerHandler(m_ip, m_port);
            //m_server.SSLServerCertificate = SslHelper.GetOrCreateSelfSignedCertificate("NameHere");
            m_server.Connected    += m_server_Connected;
            m_server.Disconnected += m_server_Disconnected;
            m_server.ReceivedFull += m_server_ReceivedFull;
            m_server.Start();
        }
Exemple #8
0
        /// <summary>
        /// Close all connection to the Rcon server and stop it
        /// </summary>
        public void Stop()
        {
            if (!IsRunning)
            {
                return;
            }
            this.NotifyAll("Server is shutting down...");

            m_server.Connected    -= m_server_Connected;
            m_server.Disconnected -= m_server_Disconnected;
            m_server.ReceivedFull -= m_server_ReceivedFull;

            m_server.DisconnectAll();
            m_server.Stop();
            m_server = null;
        }
        /// <summary>
        /// Close all connection to the Rcon server and stop it
        /// </summary>
        public void Stop()
        {
            if (!IsRunning)
            {
                return;
            }
            SendCommand(new NotificationCommand("Server is shutting down..."));

            m_server.Connected    -= m_server_Connected;
            m_server.Disconnected -= m_server_Disconnected;
            m_server.ReceivedFull -= m_server_ReceivedFull;

            m_server.DisconnectAll();
            m_server.Stop();
            m_server = null;
        }
Exemple #10
0
 private static void event_started(TcpServerHandler host)
 {
     mainProgram.WriteLine("Server is now running");
 }
		public void Stop()
		{
			if (!IsRunning)
				return;
			this.SendToAll("Server is shutting down...");

			m_server.Connected -= m_server_Connected;
			m_server.Disconnected -= m_server_Disconnected;
			m_server.ReceivedFull -= m_server_ReceivedFull;

			m_server.DisconnectAll();
			m_server.Stop();
			m_server = null;
		}