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(); } }
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); }
//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; } }
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; } }