private static void SocketRequestClose(C4Socket *socket, int status, C4Slice message) { try { _externalRequestClose?.Invoke(socket, status, message.CreateString()); } catch (Exception e) { _error?.Invoke(socket, new Exception("Error requesting socket close", e)); } }
private static void DocObserverCallback(C4DocumentObserver *observer, C4Slice docID, ulong sequence, void *context) { var idHolder = GCHandle.FromIntPtr((IntPtr)context); var id = (Guid)idHolder.Target; var obj = _ObserverMap[id]; obj._callback?.Invoke(observer, docID.CreateString(), sequence, obj._context); }
private static void OnError(C4Replicator *replicator, bool pushing, C4Slice docID, C4Error error, bool transient, void *context) { // Don't throw exceptions here, it will bubble up to native code try { var id = (long)context; var obj = _StaticMap[id]; obj._errorCallback?.Invoke(pushing, docID.CreateString(), error, transient, obj._context); } catch (Exception) { } }
private static bool PerformValidate(C4Slice docID, FLDict *body, void *context) { // Don't throw exceptions here, it will bubble up to native code try { var id = (long)context; var obj = _StaticMap[id]; var result = obj._validateFunction?.Invoke(docID.CreateString(), (IntPtr)body, obj._context); return(result.HasValue && result.Value); } catch (Exception) { return(false); } }