예제 #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);
        }
예제 #2
0
        void listen_callback(IntPtr req, int status)
        {
            UVStream stream = Create();

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