Example #1
0
        private async void btn_join_Click(object sender, EventArgs e)
        {
            var convId = this.txb_convId.Text.Trim();

            this.conversation = await client.GetConversationAsync(convId, true);

            await client.JoinAsync(this.conversation);
        }
Example #2
0
        private async void btn_join_Click(object sender, EventArgs e)
        {
            var convId = this.txb_convId.Text.Trim();

            this.conversation = await client.GetConversationAsync(convId, true);

            await client.JoinAsync(this.conversation);

            //AVIMClient avIMClient = await realtime.CreateClientAsync("junwu");
            //avIMClient.OnMessageReceived += Client_OnMessageReceived;
            //AVIMConversation avIMConversation = await avIMClient.GetConversationAsync("5940e71b8fd9c5cf89fb91b7", true);
            //if (avIMConversation != null)
            //{
            //    await avIMConversation.JoinAsync();
            //}
        }
    public void JoinLobby()
    {
        _avRealtime.CreateClientAsync(UserInfo.User).ContinueWith(t => _client = t.Result).ContinueWith(s =>
        {
            _client.OnMessageReceived += OnMessageReceived;
            Debug.Log("Joining");
            // 构建对话的时候需要指定一个 AVIMClient 实例做关联
            _lobbyConversation = AVIMConversation.CreateWithoutData(ConversationId, _client);
            _client.JoinAsync(_lobbyConversation).ContinueWith(a =>
            {
                if (a.IsFaulted)
                {
                    _lobbyConversation = null;
                    Debug.Log("Join failed");

                    return;
                }
                Debug.Log("Joined and sending message");
            });
        });
    }
Example #4
0
        public async Task InitChatSDK()
        {
            string userid = string.Empty;
            string roomid = string.Empty;

            try
            {
                userid = VenueRtcCLI.VenueRTC.Instance.getUserId();
                roomid = VenueRtcCLI.VenueRTC.Instance.getRoomId();
            }
            catch (Exception ex)
            {
                App.LogError(ex);
            }
            AVClient.Initialize("Q2BQPmQMCARUy2LY6pqc8Tk3-gzGzoHsz", "5jl51fyVTMUhHt6ddghrXNTa");
            AVRealtime realtime = new AVRealtime("Q2BQPmQMCARUy2LY6pqc8Tk3-gzGzoHsz", "5jl51fyVTMUhHt6ddghrXNTa");

            Websockets.Net.WebsocketConnection.Link();
            vIMClient = await realtime.CreateClientAsync(userid);

            AVIMConversationQuery   query         = vIMClient.GetChatRoomQuery().WhereEqualTo("name", roomid);
            List <AVIMConversation> conversations = (List <AVIMConversation>)(await query.FindAsync());

            if (conversations == null || conversations.Count == 0)
            {
                conversation = await vIMClient.CreateChatRoomAsync(roomid);
            }
            else
            {
                conversation = conversations[0];
            }

            await vIMClient.JoinAsync(conversation);

            await getHistoryMessage();

            vIMClient.OnMessageReceived += VIMClient_OnMessageReceived;
        }