public UserConnectionListener(SocketListenerSettings theSocketListenerSettings)
 {
     this.socketListenerSettings = theSocketListenerSettings;
     //buffer for all connections, double the number of connections cuz recv and send use own buffer block
     recvSendBufMenager = new BufferMenager(socketListenerSettings.MaxConnections * 2, socketListenerSettings.BufferSize);
     // Create connections count enforcer
     theMaxConnectionsEnforcer = new Semaphore(socketListenerSettings.MaxConnections, socketListenerSettings.MaxConnections);
     //pool of connections with set of max active connections
     inactiveConPool       = new ConnectionsPool(socketListenerSettings.MaxConnections);
     activeConPool         = new ConcurrentDictionary <int, Connection>();
     activeConnectionCount = 0;
 }
示例#2
0
        const string send       = "/SEND";                           //send test

        public LoginServer()
        {
            IniFile configServerFile = new IniFile("Config.ini");
            IniFile worldServerFile  = new IniFile("Worlds.ini");

            Program.port = configServerFile.GetInteger("INTERNAL", "port", 4444);
            Program.maxNumberOfConnections = configServerFile.GetInteger("INTERNAL", "maxNumberOfConnections", 1000);
            Program.bufferSize             = configServerFile.GetInteger("INTERNAL", "bufferSize", 100);
            Program.backlog          = configServerFile.GetInteger("INTERNAL", "backlog", 100);
            Program.useWhiteList     = configServerFile.GetBoolean("INTERNAL", "whiteList", false);
            Program.useBlackList     = configServerFile.GetBoolean("INTERNAL", "blackList", true);
            Program.useTempBlackList = configServerFile.GetBoolean("INTERNAL", "tempBlackList", true);
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, Program.port);

            socketSettings = new SocketListenerSettings(Program.maxNumberOfConnections, Program.backlog, Program.receivePrefixLength, Program.bufferSize, Program.sendPrefixLength, localEndPoint);
            Output.WriteLine(ConsoleColor.Green, "LoginServer config. Port: " + Program.port.ToString() + " Max connections: " + Program.maxNumberOfConnections.ToString() + " Buffer size: " + Program.bufferSize.ToString());
            worldListener = new WorldConnectionListener();
            userListener  = new UserConnectionListener(socketSettings);
        }