예제 #1
0
파일: Server.cs 프로젝트: jaras/OCTGN
        // Start the server
        private void Start()
        {
            // Creates a new thread for the server
            _serverThread = new Thread(Listen)
            {
                Name = "OCTGN.net Server"
            };
            // Flag used to wait until the server is really started
            var started = new ManualResetEvent(false);


            // Start the server
            _serverThread.Start(started);
            _broadcaster.StartBroadcasting();
            started.WaitOne();
        }
예제 #2
0
파일: Server.cs 프로젝트: wlk0/OCTGN
        public async Task Start()
        {
            if (_listenTask != null)
            {
                throw new InvalidOperationException("Server already started.");
            }

            _broadcaster.StartBroadcasting();

            _tcp.Start();

            Log.Info("Waiting for first connection");
            using (var cancellation = new CancellationTokenSource(TimeSpan.FromMinutes(1))) {
                cancellation.Token.Register(() => _tcp.Stop());
                await ListenSingle();

                Log.Info("Got first connection");
            }

            _listenTask = Listen();
        }