Beispiel #1
0
        private async Task ConnectedCallback(UvConnectRequest connect, int status, UvException error, TaskCompletionSource <int> tcs)
        {
            connect.Dispose();
            if (error != null)
            {
                tcs.SetException(error);
                return;
            }

            var writeReq = new UvWriteReq(Log);

            try
            {
                DispatchPipe.ReadStart(
                    (handle, status2, state) => ((UvListenerSecondary)state)._buf,
                    (handle, status2, state) => ((UvListenerSecondary)state).ReadStartCallback(handle, status2),
                    this);

                writeReq.Init(_thread);
                var result = await writeReq.WriteAsync(
                    DispatchPipe,
                    new ArraySegment <ArraySegment <byte> >(new[] { new ArraySegment <byte>(_pipeMessage) }));

                if (result.Error != null)
                {
                    tcs.SetException(result.Error);
                }
                else
                {
                    tcs.SetResult(0);
                }
            }
            catch (Exception ex)
            {
                DispatchPipe.Dispose();
                tcs.SetException(ex);
            }
            finally
            {
                writeReq.Dispose();
            }
        }
Beispiel #2
0
        private void StartedCallback(TaskCompletionSource <int> tcs)
        {
            var connect = new UvConnectRequest(Log);

            try
            {
                DispatchPipe.Init(_thread.Loop, _thread.QueueCloseHandle, true);
                connect.Init(_thread);
                connect.Connect(
                    DispatchPipe,
                    _pipeName,
                    (connect2, status, error, state) => ConnectCallback(connect2, status, error, (TaskCompletionSource <int>)state),
                    tcs);
            }
            catch (Exception ex)
            {
                DispatchPipe.Dispose();
                connect.Dispose();
                tcs.SetException(ex);
            }
        }
Beispiel #3
0
        private static void ConnectCallback(UvConnectRequest connect, int status, UvException error, TaskCompletionSource <int> tcs)
        {
            var listener = (UvListenerSecondary)tcs.Task.AsyncState;

            _ = listener.ConnectedCallback(connect, status, error, tcs);
        }
Beispiel #4
0
 public static extern void uv_pipe_connect(UvConnectRequest req,UvPipeHandle handle,string name,uv_connect_cb cb);
Beispiel #5
0
 public static extern void uv_tcp_connect(UvConnectRequest req,UvTcpHandle handle,ref SockAddr addr,uv_connect_cb cb);
Beispiel #6
0
 public void pipe_connect(UvConnectRequest req, UvPipeHandle handle, string name, uv_connect_cb cb)
 {
     req.Validate();
     handle.Validate();
     _uv_pipe_connect(req, handle, name, cb);
 }
Beispiel #7
0
 public void tcp_connect(UvConnectRequest req, UvTcpHandle handle, ref SockAddr addr, uv_connect_cb cb)
 {
     req.Validate();
     handle.Validate();
     _uv_tcp_connect(req, handle, ref addr, cb);
 }