Пример #1
0
        private static void UVConnectCallback(IntPtr reqHandle, Int32 status)
        {
            var req      = FromIntPtr <UVConnectRquest>(reqHandle);
            var callback = req.mCallback;
            var state    = req.mState;


            UVException error = null;

            if (status < 0)
            {
                UVIntrop.Check(status, out error);
            }

            try
            {
                if (callback != null)
                {
                    callback(req, status, error, state);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                req.Close();
            }
        }
Пример #2
0
        private unsafe static void UVReadCb(IntPtr handle, int nread, ref UVIntrop.uv_buf_t buf)
        {
            UVException ex;

            UVIntrop.Check(nread, out ex);

            UVStreamHandle target = FromIntPtr <UVStreamHandle>(handle);

            if (target == null)
            {
                throw new UVException("流已释放");
            }
            target.mReadCallback(target, nread, ex, ref buf, target.mReadCallbackState);
        }
Пример #3
0
        //todo:重载各种write

        #region  Callback
        private static void UVConnectionCb(IntPtr server, Int32 status)
        {
            UVException error;

            UVIntrop.Check(status, out error);
            UVTCPHandle handle = UVMemory.FromIntPtr <UVTCPHandle>(server);

            try
            {
                handle.mConnectionCallback(handle, status, error, handle.mConnectionCallbackState);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        private unsafe static void UVWriteCb(IntPtr reqHandle, Int32 status)
        {
            var req = FromIntPtr <UVWriteRequest>(reqHandle);

            UVException error = null;

            if (status < 0)
            {
                UVIntrop.Check(status, out error);
            }

            try
            {
                req.RaiseSended(status, error);
            }
            catch
            {
                throw;
            }
        }