コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChatServerListener"/> class.
        /// </summary>
        /// <param name="port">The port.</param>
        public ChatServerListener(int port)
        {
            this.port     = port;
            this.manager  = new ChatRoomManager();
            this.publicIp = PublicIpResolver.GetIPv4().ToString();
            this.randomNumberGenerator = RandomNumberGenerator.Create();

            this.clientCleanupTimer          = new Timer(1000 * 60); // every 60 seconds
            this.clientCleanupTimer.Elapsed += this.ClientCleanupInactiveClients;
            this.clientCleanupTimer.Start();
            this.roomCleanupTimer          = new Timer(1000 * 5); // every 5 seconds
            this.roomCleanupTimer.Elapsed += this.ClientCleanupUnusedRooms;
            this.roomCleanupTimer.Start();
        }
コード例 #2
0
        /// <inheritdoc/>
        public void Start()
        {
            if (this.gslistener != null && this.gslistener.Server.IsBound)
            {
                Logger.Debug("listener is already running.");
                return;
            }

            Logger.InfoFormat("Starting Server Listener, port {0}", this.port);
            this.gslistener = new TcpListener(IPAddress.Any, this.port);
            this.gslistener.Start();
            this.connectServer.RegisterGameServer(this.gameServerInfo, new IPEndPoint(PublicIpResolver.GetIPv4(), this.port));
            Task.Run(this.BeginAccept);
            Logger.Info("Server listener started.");
        }
コード例 #3
0
ファイル: ChatServerListener.cs プロジェクト: samik3k/OpenMU
 /// <summary>
 /// Gets the ip address of the server.
 /// </summary>
 /// <returns>The ip address of the server.</returns>
 public string GetIPAddress()
 {
     return(this.publicIp ?? (this.publicIp = PublicIpResolver.GetIPv4().ToString()));
 }