예제 #1
0
파일: Program.cs 프로젝트: johnknoop/chat
        static async Task Main(string[] args)
        {
            var gracefulShutdown = new CancellationTokenSource();

            var sigterms = Observable.Create <bool>(observer =>
            {
                Console.CancelKeyPress += (sender, eventArgs) =>
                {
                    observer.OnNext(false);
                    eventArgs.Cancel = true;
                };
                return(gracefulShutdown);
            })
                           .Do(x => gracefulShutdown.Cancel());

            if (!Server.IsRunning())
            {
                await StartAsServer(gracefulShutdown.Token, sigterms);
            }
            else
            {
                await StartAsClient(gracefulShutdown.Token, sigterms);
            }
        }