Ejemplo n.º 1
0
        public void Write(UVStream stream, byte[] data, int index, int count, Action <bool> callback)
        {
            GCHandle             datagchandle = GCHandle.Alloc(data, GCHandleType.Pinned);
            CallbackPermaRequest cpr          = new CallbackPermaRequest(RequestType.UV_WRITE);

            cpr.Callback = (status, cpr2) => {
                datagchandle.Free();
                if (callback != null)
                {
                    callback(status == 0);
                }
            };

            var ptr = (IntPtr)(datagchandle.AddrOfPinnedObject().ToInt64() + index);

            int r;

            if (UV.isUnix)
            {
                UnixBufferStruct[] buf = new UnixBufferStruct[1];
                buf[0] = new UnixBufferStruct(ptr, count);
                r      = uv_write2_unix(cpr.Handle, NativeHandle, buf, 1, stream.NativeHandle, CallbackPermaRequest.StaticEnd);
            }
            else
            {
                WindowsBufferStruct[] buf = new WindowsBufferStruct[1];
                buf[0] = new WindowsBufferStruct(ptr, count);
                r      = uv_write2_win(cpr.Handle, NativeHandle, buf, 1, stream.NativeHandle, CallbackPermaRequest.StaticEnd);
            }

            Ensure.Success(r, Loop);
        }
Ejemplo n.º 2
0
        void listen_callback(IntPtr req, int status)
        {
            UVStream stream = Create();

            uv_accept(req, stream.handle);
            OnListen(stream);
        }
Ejemplo n.º 3
0
 public void Write(UVStream stream, byte[] data)
 {
     Write(stream, data, 0, data.Length, null);
 }
Ejemplo n.º 4
0
 public void Write(UVStream stream, byte[] data, int index)
 {
     Write(stream, data, index, data.Length - index, null);
 }
Ejemplo n.º 5
0
 public void Write(UVStream stream, byte[] data, int index, int count)
 {
     Write(stream, data, index, count, null);
 }
Ejemplo n.º 6
0
 public void Write(UVStream stream, byte[] data, Action <bool> callback)
 {
     Write(stream, data, 0, data.Length, callback);
 }
Ejemplo n.º 7
0
 public void Write(UVStream stream, byte[] data, int index, Action <bool> callback)
 {
     Write(stream, data, index, data.Length - index, callback);
 }