internal static void OnPresenceChanged(IntPtr address) { OnPresenceChangedCallback callback = null; PresenceChangedCallbackInfo callbackInfo = null; if (Helper.TryGetAndRemoveCallback <OnPresenceChangedCallback, PresenceChangedCallbackInfoInternal, PresenceChangedCallbackInfo>(address, out callback, out callbackInfo)) { callback(callbackInfo); } }
/// <summary> /// Register to receive notifications when presence changes. If the returned NotificationId is valid, you must call RemoveNotifyOnPresenceChanged when you no longer wish to /// have your NotificationHandler called /// <seealso cref="Common.InvalidNotificationid" /> /// <seealso cref="RemoveNotifyOnPresenceChanged" /> /// </summary> /// <param name="clientData">Data the is returned to when NotificationHandler is invoked</param> /// <param name="notificationHandler">The callback to be fired when a presence change occurs</param> /// <returns> /// Notification ID representing the registered callback if successful, an invalid NotificationId if not /// </returns> public ulong AddNotifyOnPresenceChanged(AddNotifyOnPresenceChangedOptions options, object clientData, OnPresenceChangedCallback notificationHandler) { var optionsInternal = Helper.CopyProperties <AddNotifyOnPresenceChangedOptionsInternal>(options); var notificationHandlerInternal = new OnPresenceChangedCallbackInternal(OnPresenceChanged); var clientDataAddress = IntPtr.Zero; Helper.AddCallback(ref clientDataAddress, clientData, notificationHandler, notificationHandlerInternal); var funcResult = EOS_Presence_AddNotifyOnPresenceChanged(InnerHandle, ref optionsInternal, clientDataAddress, notificationHandlerInternal); Helper.TryMarshalDispose(ref optionsInternal); Helper.TryAssignNotificationIdToCallback(clientDataAddress, funcResult); var funcResultReturn = Helper.GetDefault <ulong>(); Helper.TryMarshalGet(funcResult, out funcResultReturn); return(funcResultReturn); }
/// <summary> /// Register to receive notifications when presence changes. If the returned NotificationId is valid, you must call RemoveNotifyOnPresenceChanged when you no longer wish to /// have your NotificationHandler called /// <seealso cref="Common.InvalidNotificationid" /> /// <seealso cref="RemoveNotifyOnPresenceChanged" /> /// </summary> /// <param name="clientData">Data the is returned to when NotificationHandler is invoked</param> /// <param name="notificationHandler">The callback to be fired when a presence change occurs</param> /// <returns> /// Notification ID representing the registered callback if successful, an invalid NotificationId if not /// </returns> public ulong AddNotifyOnPresenceChanged(AddNotifyOnPresenceChangedOptions options, object clientData, OnPresenceChangedCallback notificationHandler) { System.IntPtr optionsAddress = new System.IntPtr(); Helper.TryMarshalSet <AddNotifyOnPresenceChangedOptionsInternal, AddNotifyOnPresenceChangedOptions>(ref optionsAddress, options); var clientDataAddress = System.IntPtr.Zero; var notificationHandlerInternal = new OnPresenceChangedCallbackInternal(OnPresenceChangedCallbackInternalImplementation); Helper.AddCallback(ref clientDataAddress, clientData, notificationHandler, notificationHandlerInternal); var funcResult = EOS_Presence_AddNotifyOnPresenceChanged(InnerHandle, optionsAddress, clientDataAddress, notificationHandlerInternal); Helper.TryMarshalDispose(ref optionsAddress); Helper.TryAssignNotificationIdToCallback(clientDataAddress, funcResult); return(funcResult); }