Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }