/// <summary>
        /// 独立信令 用户自定义控制指令接口
        /// 该接口用于在频道中透传一些自定义指令,协助频道管理
        /// </summary>
        /// <param name="param">控制通知的传入参数,接收方to_填空为群发,只支持在线通知</param>
        /// <param name="cb">结果回调见NimSignalingDef.cs</param>
        public static void Control(NIMSignalingControlParam param, NimSignalingOptControlHandler cb)
        {
            int    nSizeOfParam = Marshal.SizeOf(param);
            IntPtr param_ptr    = Marshal.AllocHGlobal(nSizeOfParam);

            try
            {
                Marshal.StructureToPtr(param, param_ptr, false);
                var user_ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
                SignalingNativeMethods.nim_signaling_control(param_ptr, NimSignalingControlCb, user_ptr);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                Marshal.FreeHGlobal(param_ptr);
            }
        }
Example #2
0
        /// <summary>
        /// 独立信令 用户自定义控制指令接口
        /// 该接口用于在频道中透传一些自定义指令,协助频道管理
        /// </summary>
        /// <param name="param">控制通知的传入参数,接收方to_填空为群发,只支持在线通知</param>
        /// <param name="cb">结果回调见NimSignalingDef.cs</param>
        public static void Control(NIMSignalingControlParam param, NimSignalingOptControlHandler cb)
        {
            NIMSignalingControlParam_C param_c = SignalHelper.GetNativeNIMSignalingControlParam(param);
            int    nSizeOfParam = Marshal.SizeOf(param_c);
            IntPtr param_ptr    = Marshal.AllocHGlobal(nSizeOfParam);

            try
            {
                Marshal.StructureToPtr(param_c, param_ptr, false);
                var user_ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
                SignalingNativeMethods.nim_signaling_control(param_ptr, NimSignalingControlCb, user_ptr);
            }
            catch (Exception)
            {
                cb?.Invoke(NIMSignalingControlResCode.kAbnormal);
            }
            finally
            {
                Marshal.FreeHGlobal(param_ptr);
            }
        }