示例#1
0
        private async Task <string> InternalGenerateNewModeratorAndThread()
        {
            var moderator = await InternalGenerateAdhocUser();

            var        userCredential = new CommunicationUserCredential(moderator.token);
            ChatClient chatClient     = new ChatClient(new Uri(_chatGatewayUrl), userCredential);
            List <ChatThreadMember> chatThreadMembers = new List <ChatThreadMember>
            {
                new ChatThreadMember(new CommunicationUser(moderator.identity))
            };
            ChatThreadClient chatThreadClient = await chatClient.CreateChatThreadAsync(GUID_FOR_INITIAL_TOPIC_NAME, chatThreadMembers);

            _store.Store.Add(chatThreadClient.Id, moderator);
            return(chatThreadClient.Id);
        }
        private async Task <string> InternalGenerateNewModeratorAndThread()
        {
            var moderator = await _userTokenManager.GenerateTokenAsync(_resourceConnectionString);

            var moderatorId    = moderator.User.Id;
            var moderatorToken = moderator.AccessToken.Token;

            ChatClient chatClient = new ChatClient(
                new Uri(_chatGatewayUrl),
                new CommunicationTokenCredential(moderatorToken));

            List <ChatParticipant> chatParticipants = new List <ChatParticipant>
            {
                new ChatParticipant(new CommunicationUserIdentifier(moderatorId))
            };

            Response <CreateChatThreadResult> result = await chatClient.CreateChatThreadAsync(GUID_FOR_INITIAL_TOPIC_NAME, chatParticipants);

            var threadId = result.Value.ChatThread.Id;

            _chatThreadStore.Store.Add(threadId, moderatorId);
            return(threadId);
        }