예제 #1
0
        /// <summary>
        /// Initializes a new instance of the ServerSocket.
        /// </summary>
        /// <param name="settings">The settings to use with this ServerSocket.</param>
        public ServerSocket(ServerSocketSettings settings)
        {
            _settings = settings;

            _bufferManager =
                new BufferManager(
                    (_settings.BufferSize * _settings.NumOfSaeaForRec) + (_settings.BufferSize * _settings.NumOfSaeaForSend),
                    _settings.BufferSize);
            _poolOfAcceptEventArgs = new SocketAsyncEventArgsPool(_settings.MaxSimultaneousAcceptOps);
            _poolOfRecEventArgs    = new SocketAsyncEventArgsPool(_settings.NumOfSaeaForRec);
            _poolOfSendEventArgs   = new SocketAsyncEventArgsPool(_settings.NumOfSaeaForSend);

            _maxConnectionsEnforcer = new SemaphoreSlim(_settings.MaxConnections, _settings.MaxConnections);
            _maxSaeaSendEnforcer    = new SemaphoreSlim(_settings.NumOfSaeaForSend, _settings.NumOfSaeaForSend);
            _maxAcceptOpsEnforcer   = new SemaphoreSlim(_settings.MaxSimultaneousAcceptOps,
                                                        _settings.MaxSimultaneousAcceptOps);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the ServerSocket.
        /// </summary>
        /// <param name="settings">The settings to use with this ServerSocket.</param>
        public ServerSocket(ServerSocketSettings settings)
        {
            _settings = settings;

            _bufferManager =
                new BufferManager(
                    (_settings.BufferSize*_settings.NumOfSaeaForRec) + (_settings.BufferSize*_settings.NumOfSaeaForSend),
                    _settings.BufferSize);
            _poolOfAcceptEventArgs = new SocketAsyncEventArgsPool(_settings.MaxSimultaneousAcceptOps);
            _poolOfRecEventArgs = new SocketAsyncEventArgsPool(_settings.NumOfSaeaForRec);
            _poolOfSendEventArgs = new SocketAsyncEventArgsPool(_settings.NumOfSaeaForSend);

            _maxConnectionsEnforcer = new SemaphoreSlim(_settings.MaxConnections, _settings.MaxConnections);
            _maxSaeaSendEnforcer = new SemaphoreSlim(_settings.NumOfSaeaForSend, _settings.NumOfSaeaForSend);
            _maxAcceptOpsEnforcer = new SemaphoreSlim(_settings.MaxSimultaneousAcceptOps,
                                                     _settings.MaxSimultaneousAcceptOps);
        }
예제 #3
0
        static void Main(string[] args)
        {
            if (!Directory.Exists("Settings") && !File.Exists("Settings/config.ini"))
            {
                Configuration.CreateFolder("Settings");
                Configuration.CreateFile("Settings/config.ini");
                Configuration.SetConfigurationFile("Settings/config.ini");
                Configuration.AppendValues("version", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            }

            Configuration.SetConfigurationFile("Settings/config.ini");
            Configuration.ReadConfigurationFile();
            Configuration.PopValue<string>("version", out Version);

            Logging.SetTitle("FerriEmulator - v{0}", Version);
            Logging.WriteTagLine("Debug", "Initializing Ferri v{0} for {1}", Version, Environment.UserName);

            dbManager.CreateConnectionString();

            GetHabboHotel.LoadHH();

            ServerSocketSettings Settings = new ServerSocketSettings()
            {
                Backlog = 10,
                BufferSize = 512,
                Endpoint = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 30000),
                MaxConnections = 10000,
                MaxSimultaneousAcceptOps = 15,
                NumOfSaeaForRec = 10000,
                NumOfSaeaForSend = 20000
            };

            Network = new ServerSocket(Settings);
            Network.Init();
            Network.StartListen();

            Remote = new RemoteNetwork(30001);
            Logging.WriteTagLine("Ready", "Initialized FerriEmulator, ready for connections!");

            Console.WriteLine();

            while (true)
                Console.ReadLine();
        }