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); }
void listen_callback(IntPtr req, int status) { UVStream stream = Create(); uv_accept(req, stream.handle); OnListen(stream); }
public void Write(UVStream stream, byte[] data) { Write(stream, data, 0, data.Length, null); }
public void Write(UVStream stream, byte[] data, int index) { Write(stream, data, index, data.Length - index, null); }
public void Write(UVStream stream, byte[] data, int index, int count) { Write(stream, data, index, count, null); }
public void Write(UVStream stream, byte[] data, Action <bool> callback) { Write(stream, data, 0, data.Length, callback); }
public void Write(UVStream stream, byte[] data, int index, Action <bool> callback) { Write(stream, data, index, data.Length - index, callback); }