示例#1
0
        private static void NimSignalingChannelsSyncCallback(IntPtr info_list, int size, IntPtr user_data)
        {
            List <NIMSignalingChannelDetailedinfo> channels = new List <NIMSignalingChannelDetailedinfo>();

            if (info_list != IntPtr.Zero)
            {
                for (int i = 0; i < size; i++)
                {
                    NIMSignalingChannelDetailedinfo channel_detailed_info = new NIMSignalingChannelDetailedinfo();

                    IntPtr detailed_ptr = NimUtility.IntPtrExtensions.Increment(info_list, i * Marshal.SizeOf(typeof(NIMSignalingChannelDetailedinfo_C)));
                    NIMSignalingChannelDetailedinfo_C detailed_info = (NIMSignalingChannelDetailedinfo_C)Marshal.PtrToStructure(detailed_ptr, typeof(NIMSignalingChannelDetailedinfo_C));

                    for (int j = 0; j < detailed_info.member_size_; j++)
                    {
                        IntPtr src_data = NimUtility.IntPtrExtensions.Increment(detailed_info.members_, j * Marshal.SizeOf(typeof(NIMSignalingMemberInfo_C)));
                        NIMSignalingMemberInfo_C member_info_c = (NIMSignalingMemberInfo_C)Marshal.PtrToStructure(src_data, typeof(NIMSignalingMemberInfo_C));
                        NIMSignalingMemberInfo   member_info   = SignalHelper.NIMSignalingMemberFromC(member_info_c);
                        channel_detailed_info.members_.Add(member_info);
                    }

                    channel_detailed_info.channel_info_ = SignalHelper.NIMSignalingChannelInfoFromC(detailed_info.channel_info_);
                    channels.Add(channel_detailed_info);
                }
            }
            NimUtility.DelegateConverter.Invoke <NimSignalingChannelsSyncHandler>(user_data, channels);
        }
示例#2
0
        private static void NimSignalingOptAcceptCallback(int code, IntPtr opt_res_param, IntPtr user_data)
        {
            NIMSignalingAcceptResParam accept_res_param = new NIMSignalingAcceptResParam();

            accept_res_param.info_ = new NIMSignalingChannelDetailedinfo();
            NIMSignalingJoinResParam_C res_param_c = (NIMSignalingJoinResParam_C)Marshal.PtrToStructure(opt_res_param, typeof(NIMSignalingJoinResParam_C));

            if (res_param_c != null)
            {
                accept_res_param.info_.channel_info_ = SignalHelper.NIMSignalingChannelInfoFromC(res_param_c.info_.channel_info_);
                for (int i = 0; i < res_param_c.info_.member_size_; i++)
                {
                    IntPtr src_data = NimUtility.IntPtrExtensions.Increment(res_param_c.info_.members_, i * Marshal.SizeOf(typeof(NIMSignalingMemberInfo_C)));
                    NIMSignalingMemberInfo_C member_info_c = (NIMSignalingMemberInfo_C)Marshal.PtrToStructure(src_data, typeof(NIMSignalingMemberInfo_C));
                    NIMSignalingMemberInfo   member_info   = SignalHelper.NIMSignalingMemberFromC(member_info_c);
                    accept_res_param.info_.members_.Add(member_info);
                }
            }

            NIMSignalingRejectOrAcceptResCode res_code = NIMSignalingRejectOrAcceptResCode.kUnknown;

            try
            {
                res_code = (NIMSignalingRejectOrAcceptResCode)Enum.Parse(typeof(NIMSignalingRejectOrAcceptResCode), code.ToString());
            }
            catch
            {
                res_code = NIMSignalingRejectOrAcceptResCode.kUnknown;
            }
            NimUtility.DelegateConverter.Invoke <NimSignalingOptAcceptHandler>(user_data, res_code, accept_res_param);
        }
示例#3
0
        private static void NimSignalingOptCreateCallback(int code, IntPtr opt_res_param, IntPtr user_data)
        {
            NIMSignalingCreateResParam res_param = new NIMSignalingCreateResParam();

            if (opt_res_param != IntPtr.Zero)
            {
                NIMSignalingCreateResParam_C res_param_c = (NIMSignalingCreateResParam_C)Marshal.PtrToStructure(opt_res_param, typeof(NIMSignalingCreateResParam_C));
                res_param.channel_info_ = SignalHelper.NIMSignalingChannelInfoFromC(res_param_c.channel_info_);
            }
            NimUtility.DelegateConverter.Invoke <NimSignalingOptCreateHandler>(user_data, code, res_param);
        }
示例#4
0
        void SetNotificationBaseInfo(IntPtr ptr)
        {
            var notification = NimUtility.Utilities.IntPtrToStructure <CNotification>(ptr);
            var notifyData   = NimUtility.Utilities.IntPtrToStructure <CNotificationData>(notification.Data);

            custom_info_     = NimUtility.Utilities.MarshalUtf8String(notifyData.custom_info_);
            from_account_id_ = NimUtility.Utilities.MarshalUtf8String(notifyData.from_account_id_);
            msg_id_          = notifyData.msg_id_;
            var cChannel = NimUtility.Utilities.IntPtrToStructure <NIMSignalingChannelInfo_C>(notifyData.channel_info_);

            channel_info_ = SignalHelper.NIMSignalingChannelInfoFromC(cChannel);
        }
示例#5
0
        private static void NimSignalingOptJoinCallback(int code, IntPtr opt_res_param, IntPtr user_data)
        {
            NIMSignalingJoinResParam res_param = new NIMSignalingJoinResParam();

            NIMSignalingJoinResParam_C res_param_c = (NIMSignalingJoinResParam_C)Marshal.PtrToStructure(opt_res_param, typeof(NIMSignalingJoinResParam_C));

            res_param.info_.channel_info_ = SignalHelper.NIMSignalingChannelInfoFromC(res_param_c.info_.channel_info_);
            for (int i = 0; i < res_param_c.info_.member_size_; i++)
            {
                IntPtr src_data = NimUtility.IntPtrExtensions.Increment(res_param_c.info_.members_, i * Marshal.SizeOf(typeof(NIMSignalingMemberInfo_C)));
                NIMSignalingMemberInfo_C member_info_c = (NIMSignalingMemberInfo_C)Marshal.PtrToStructure(src_data, typeof(NIMSignalingMemberInfo_C));
                NIMSignalingMemberInfo   member_info   = SignalHelper.NIMSignalingMemberFromC(member_info_c);
                res_param.info_.members_.Add(member_info);
            }

            NimUtility.DelegateConverter.Invoke <NimSignalingOptJoinHandler>(user_data, code, res_param);
        }
示例#6
0
        private static void NimSignalingMembersSyncCallback(IntPtr detailed_info, IntPtr user_data)
        {
            NIMSignalingChannelDetailedinfo channel_detailed_info = new NIMSignalingChannelDetailedinfo();


            if (detailed_info != IntPtr.Zero)
            {
                NIMSignalingChannelDetailedinfo_C res_param = (NIMSignalingChannelDetailedinfo_C)Marshal.PtrToStructure(detailed_info, typeof(NIMSignalingChannelDetailedinfo_C));
                channel_detailed_info.channel_info_ = SignalHelper.NIMSignalingChannelInfoFromC(res_param.channel_info_);
                for (int i = 0; i < res_param.member_size_; i++)
                {
                    IntPtr src_data = NimUtility.IntPtrExtensions.Increment(res_param.members_, i * Marshal.SizeOf(typeof(NIMSignalingMemberInfo)));
                    NIMSignalingMemberInfo member_info = (NIMSignalingMemberInfo)Marshal.PtrToStructure(src_data, typeof(NIMSignalingMemberInfo));
                    channel_detailed_info.members_.Add(member_info);
                }
            }

            NimUtility.DelegateConverter.Invoke <NimSignalingMembersSyncHandler>(user_data, channel_detailed_info);
        }
示例#7
0
        public void SetData(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                return;
            }
            ChannelDetail             channelDetail = (ChannelDetail)Marshal.PtrToStructure(ptr, typeof(ChannelDetail));
            NIMSignalingChannelInfo_C channel       = (NIMSignalingChannelInfo_C)Marshal.PtrToStructure(channelDetail.Channel, typeof(NIMSignalingChannelInfo_C));

            channel_info_ = SignalHelper.NIMSignalingChannelInfoFromC(channel);
            if (channelDetail.MembersCount > 0)
            {
                for (int i = 0; i < channelDetail.MembersCount; i++)
                {
                    var memberPtr = Marshal.ReadIntPtr(channelDetail.Members, i * Marshal.SizeOf(typeof(IntPtr)));
                    var member    = (NIMSignalingMemberInfo)Marshal.PtrToStructure(memberPtr, typeof(NIMSignalingMemberInfo));
                    members_.Add(member);
                }
            }
        }
示例#8
0
        private static void NimSignalingOptJoinCallback(int code, IntPtr opt_res_param, IntPtr user_data)
        {
            NIMSignalingJoinResParam res_param = new NIMSignalingJoinResParam();

            if (code == (int)NIM.ResponseCode.kNIMResSuccess)
            {
                res_param = new NIMSignalingJoinResParam();
                JoinResult                result        = (JoinResult)Marshal.PtrToStructure(opt_res_param, typeof(JoinResult));
                ChannelDetail             channelDetail = (ChannelDetail)Marshal.PtrToStructure(result.DetailInfo, typeof(ChannelDetail));
                NIMSignalingChannelInfo_C channel       = (NIMSignalingChannelInfo_C)Marshal.PtrToStructure(channelDetail.Channel, typeof(NIMSignalingChannelInfo_C));
                if (channelDetail.MembersCount > 0)
                {
                    NIMSignalingMemberInfo[] members = new NIMSignalingMemberInfo[channelDetail.MembersCount];
                    for (int i = 0; i < channelDetail.MembersCount; i++)
                    {
                        var ptr = Marshal.ReadIntPtr(channelDetail.Members, i * Marshal.SizeOf(typeof(IntPtr)));
                        members[i] = (NIMSignalingMemberInfo)Marshal.PtrToStructure(ptr, typeof(NIMSignalingMemberInfo));
                    }
                    res_param.info_.members_.AddRange(members);
                }
                res_param.info_.channel_info_ = SignalHelper.NIMSignalingChannelInfoFromC(channel);
            }
            NimUtility.DelegateConverter.Invoke <NimSignalingOptJoinHandler>(user_data, code, res_param);
        }