コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChatServer" /> class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="addressResolver">The address resolver which returns the address on which the listener will be bound to.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 /// <param name="plugInManager">The plug in manager.</param>
 public ChatServer(ChatServerSettings settings, IIpAddressResolver addressResolver, ILoggerFactory loggerFactory, PlugInManager plugInManager)
 {
     this.loggerFactory               = loggerFactory;
     this.logger                      = loggerFactory.CreateLogger <ChatServer>();
     this.settings                    = settings;
     this.addressResolver             = addressResolver;
     this.manager                     = new ChatRoomManager(loggerFactory);
     this.randomNumberGenerator       = RandomNumberGenerator.Create();
     this.clientCleanupTimer          = new Timer(this.settings.ClientCleanUpInterval.TotalMilliseconds);
     this.clientCleanupTimer.Elapsed += this.ClientCleanupInactiveClients;
     this.clientCleanupTimer.Start();
     this.roomCleanupTimer          = new Timer(this.settings.RoomCleanUpInterval.TotalMilliseconds);
     this.roomCleanupTimer.Elapsed += this.ClientCleanupUnusedRooms;
     this.roomCleanupTimer.Start();
     foreach (var endpoint in this.settings.Endpoints)
     {
         var listener = new ChatServerListener(endpoint, plugInManager, loggerFactory);
         listener.ClientAccepted  += this.ChatClientAccepted;
         listener.ClientAccepting += this.ChatClientAccepting;
         this.listeners.Add(listener);
     }
 }
コード例 #2
0
ファイル: ChatServer.cs プロジェクト: guser9822/OpenMU
        /// <summary>
        /// Initializes a new instance of the <see cref="ChatServer" /> class.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="addressResolver">The address resolver which returns the address on which the listener will be bound to.</param>
        public ChatServer(ChatServerSettings settings, IIpAddressResolver addressResolver)
        {
            this.settings                    = settings;
            this.addressResolver             = addressResolver;
            this.manager                     = new ChatRoomManager();
            this.randomNumberGenerator       = RandomNumberGenerator.Create();
            this.clientCleanupTimer          = new Timer(this.settings.ClientCleanUpInterval.TotalMilliseconds);
            this.clientCleanupTimer.Elapsed += this.ClientCleanupInactiveClients;
            this.clientCleanupTimer.Start();
            this.roomCleanupTimer          = new Timer(this.settings.RoomCleanUpInterval.TotalMilliseconds);
            this.roomCleanupTimer.Elapsed += this.ClientCleanupUnusedRooms;
            this.roomCleanupTimer.Start();
            var plugInManager = new PlugInManager();

            plugInManager.DiscoverAndRegisterPlugInsOf <INetworkEncryptionFactoryPlugIn>();
            foreach (var endpoint in this.settings.Endpoints)
            {
                var listener = new ChatServerListener(endpoint, plugInManager);
                listener.ClientAccepted  += this.ChatClientAccepted;
                listener.ClientAccepting += this.ChatClientAccepting;
                this.listeners.Add(listener);
            }
        }