Ejemplo n.º 1
0
        private static void OnConnection(UvConnectRequest req, int status, Exception exception, object state)
        {
            var client = (UvTcpClient)state;

            var connection = new UvTcpConnection(client._thread, client._connectSocket);

            client._connectTcs.TrySetResult(connection);
        }
Ejemplo n.º 2
0
 private static async void ExecuteCallback(UvTcpListener listener, UvTcpConnection connection)
 {
     try
     {
         await listener._callback?.Invoke(connection);
     }
     catch
     {
         // Swallow exceptions
     }
     finally
     {
         // Dispose the connection on task completion
         connection.Dispose();
     }
 }
Ejemplo n.º 3
0
        private static void OnConnectionCallback(UvStreamHandle listenSocket, int status, Exception error, object state)
        {
            var listener = (UvTcpListener)state;

            var acceptSocket = new UvTcpHandle();

            try
            {
                acceptSocket.Init(listener._thread.Loop, null);
                acceptSocket.NoDelay(true);
                listenSocket.Accept(acceptSocket);
                var connection = new UvTcpConnection(listener._thread, acceptSocket);
                listener._callback?.Invoke(connection);
            }
            catch (UvException)
            {
                acceptSocket.Dispose();
            }
        }