private void CreateMultiVChatRoomCallback(int code, long channel_id, string json_extension) { if (code == 200) { NIM.NIMJoinRoomJsonEx joinRoomJsonEx = new NIMJoinRoomJsonEx(); CustomLayout layout_json = new CustomLayout(); layout_json.Hostarea = new HostArea(); layout_json.Background = new BackGround(); joinRoomJsonEx.Layout = layout_json.Serialize(); //创建房间成功,将内容抛至UI线程 Action action = () => { if (VChatAPI.JoinRoom(NIMVideoChatMode.kNIMVideoChatModeVideo, room_name, joinRoomJsonEx, _joinroomcb)) { //调用成功 } else { string info = String.Format("加入房间-{0}-失败", room_name); MessageBox.Show(info); } }; this.Invoke(action); } else { Action action = () => { MessageBox.Show("创建房间失败-错误码:" + code.ToString()); }; this.BeginInvoke(action); } }
/// <summary> /// 加入一个多人房间(进入房间后成员变化等,等同点对点NIMVChatHander) /// </summary> /// <param name="mode">音视频通话类型</param> /// <param name="room_name">房间名</param> /// <param name="joinRoomInfo">json封装类,见NIMJoinRoomJsonEx</param> /// <param name="cb">cb 结果回调,返回的json_extension扩展字段中包含 "custom_info","session_id"</param> /// <returns>bool true 调用成功,false 调用失败可能有正在进行的通话</returns> public static bool JoinRoom(NIMVideoChatMode mode, string room_name, NIMJoinRoomJsonEx joinRoomInfo, NIMVChatOpt2Handler cb) { #if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN if (joinRoomInfo == null) { joinRoomInfo = new NIMJoinRoomJsonEx(); } string json_extension = joinRoomInfo.Serialize(); var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb); return(VChatNativeMethods.nim_vchat_join_room(mode, room_name, json_extension, VChatOpt2Cb, ptr)); #else return(false); #endif }
/// <summary> /// 加入一个多人房间(进入房间后成员变化等,等同点对点NIMVChatHander) /// </summary> /// <param name="mode">音视频通话类型</param> /// <param name="room_name">房间名</param> /// <param name="joinRoomInfo">json封装类,见NIMJoinRoomJsonEx</param> /// <param name="cb">cb 结果回调,返回的json_extension扩展字段中包含 "custom_info","session_id"</param> /// <returns>bool true 调用成功,false 调用失败可能有正在进行的通话</returns> public static bool JoinRoom(NIMVideoChatMode mode, string room_name, NIMJoinRoomJsonEx joinRoomInfo, NIMVChatOpt2Handler cb) { if (joinRoomInfo == null) { joinRoomInfo = new NIMJoinRoomJsonEx(); #if NIMAPI_UNDER_WIN_DESKTOP_ONLY CustomLayout layout = new CustomLayout(); layout.Hostarea = new HostArea(); layout.Background = new BackGround(); joinRoomInfo.Layout = layout.Serialize(); #endif } string json_extension = joinRoomInfo.Serialize(); var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb); return(VChatNativeMethods.nim_vchat_join_room(mode, room_name, json_extension, VChatOpt2Cb, ptr)); }
private void button1_Click(object sender, EventArgs e) { // string json_extension = "{\"session_id\":\"\"}"; _room_name = tb_roomid.Text; NIM.NIMJoinRoomJsonEx joinRoomJsonEx = new NIMJoinRoomJsonEx(); CustomLayout layout = new CustomLayout(); layout.Hostarea = new HostArea(); layout.Background = new BackGround(); joinRoomJsonEx.Layout = layout.Serialize(); if (VChatAPI.JoinRoom(NIMVideoChatMode.kNIMVideoChatModeVideo, _room_name, joinRoomJsonEx, _joinroomcb)) { //调用成功 } else { Action action = () => { MessageBox.Show("JoinRoom 调用失败:"); }; this.BeginInvoke(action); } }