示例#1
0
 private static void NIMPushEventCbFunc(int res_code, string event_info_json, string json_extension, IntPtr user_data)
 {
     if (user_data != IntPtr.Zero)
     {
         var info = NIMEventInfo.Deserialize(event_info_json);
         DelegateConverter.Invoke <PushEventDelegate>(user_data, (ResponseCode)res_code, info);
     }
 }
示例#2
0
        /// <summary>
        /// 发布事件
        /// </summary>
        /// <param name="info">事件信息</param>
        /// <param name="cb"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool Publish(NIMEventInfo info, PublishEventDelegate cb, object data = null)
        {
            if ((info.Type == (int)NIMEventType.kNIMEventTypeOnlineState && info.Value >= (int)NIMEventOnlineStateValue.kNIMEventOnlineStateValueCustom) ||
                info.Value >= (int)NIMEventType.kNIMEventTypeCustom)
            {
                var ptr  = DelegateConverter.ConvertToIntPtr(cb);
                var json = info.Serialize();
                NIMSubscribeNativeMethods.nim_publish_event(json, null, PublishResultCallback, ptr);
                return(true);
            }

            return(false);
        }