Ejemplo n.º 1
0
        private void RunLoop()
        {
            Uv = new Uv();

            Loop = new UvLoopHandle();
            Loop.Init(Uv);

            _postHandle = new UvAsyncHandle();
            _postHandle.Init(Loop, OnPost, _queueCloseCallback);

            _running.Set();

            Uv.run(Loop, 0);
        }
        public void AsyncCanBeSent()
        {
            var loop = new UvLoopHandle(_logger);

            loop.Init(_uv);
            var trigger = new UvAsyncHandle(_logger);
            var called  = false;

            trigger.Init(loop, () =>
            {
                called = true;
                trigger.Dispose();
            }, (a, b) => { });
            trigger.Send();
            loop.Run();
            loop.Dispose();
            Assert.True(called);
        }
Ejemplo n.º 3
0
        private void RunLoop()
        {
            Uv = new Uv();

            Loop = new UvLoopHandle();
            Loop.Init(Uv);

            _shutdownPostHandle = new UvAsyncHandle();
            _shutdownPostHandle.Init(Loop, OnPost, _queueCloseCallback);

            _listenSocket = new UvTcpHandle();
            _listenSocket.Init(Loop, _queueCloseCallback);
            _listenSocket.NoDelay(true);
            _listenSocket.Bind(new IPEndPoint(_ip, _port));

            _listenSocket.Listen(10, _onConnectionCallback, this);

            Uv.run(Loop, 0);
        }
Ejemplo n.º 4
0
        private void RunLoop()
        {
            Uv = new Uv();

            Loop = new UvLoopHandle();
            Loop.Init(Uv);

            _postHandle = new UvAsyncHandle();
            _postHandle.Init(Loop, OnPost, null);

            _running.Set();

            Uv.run(Loop, 0);

            _postHandle.Reference();
            _postHandle.Dispose();

            Uv.run(Loop, 0);

            Loop.Dispose();
        }
Ejemplo n.º 5
0
        private void RunLoop()
        {
            Uv = new Uv();

            Loop = new UvLoopHandle();
            Loop.Init(Uv);

            _shutdownPostHandle = new UvAsyncHandle();
            _shutdownPostHandle.Init(Loop, OnPost, _queueCloseCallback);

            _connectSocket = new UvTcpHandle();
            _connectSocket.Init(Loop, _queueCloseCallback);
            _connectSocket.NoDelay(true);

            var connectReq = new UvConnectRequest();

            connectReq.Init(Loop);
            connectReq.Connect(_connectSocket, new IPEndPoint(_ip, _port), OnConnection, this);

            Uv.run(Loop, 0);
        }
Ejemplo n.º 6
0
        private void RunLoop()
        {
            Uv  = new Libuv();
            Log = new KestrelTrace(new LoggerFactory().CreateLogger <UvTcpListener>());

            Loop = new UvLoopHandle(Log);
            Loop.Init(Uv);

            _shutdownPostHandle = new UvAsyncHandle(Log);
            _shutdownPostHandle.Init(Loop, OnPost, _queueCloseCallback);

            _listenSocket = new UvTcpHandle(Log);
            _listenSocket.Init(Loop, _queueCloseCallback);
            _listenSocket.NoDelay(true);

            string host = null;

            if (_ip == IPAddress.Any)
            {
                host = "*";
            }
            else if (_ip == IPAddress.Loopback)
            {
                host = "localhost";
            }
            else
            {
                host = _ip.ToString();
            }

            var url     = $"http://{host}:{_port}";
            var address = Microsoft.AspNetCore.Server.Kestrel.ServerAddress.FromUrl(url);

            _listenSocket.Bind(address);

            _listenSocket.Listen(10, _onConnectionCallback, this);

            Uv.run(Loop, 0);
        }