Example #1
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;
        }