ChatterBox.Server.ChatterBoxServer.Run C# (CSharp) Method

Run() public method

public Run ( ) : void
return void
        public void Run()
        {
            WNSAuthentication.Instance.AuthenticateWithWNS();

            Logger.Info($"Starting TCP listener on port {Port}");
            var listener = new TcpListener(IPAddress.Any, Port);
            listener.Start();

            Logger.Info($"Starting heartbeat timer with interval {_heartBeatTimer.Interval}");
            _heartBeatTimer.Start();


            Task.Run(async () =>
            {
                while (true)
                {
                    try
                    {
                        HandleNewConnection(await listener.AcceptTcpClientAsync());
                    }
                    catch (Exception ex)
                    {
                        Logger.Fatal("Exception occred when creating a new client session", ex);
                    }
                }
            });
        }

Usage Example

Example #1
0
 private static void Main()
 {
     try
     {
         var signalingServer = new ChatterBoxServer();
         signalingServer.Run();
         Console.ReadLine();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.ReadLine();
     }
 }