Пример #1
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);
                }
            }
        }
Пример #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);
        }