新闻详情

新闻详情

首页 / 资讯中心 / 详情

【研发类-框架和库Skills】azure-communication-chat-java 技能

发布时间:2026/11/4 4:35:51来源:尧图网络
【研发类-框架和库Skills】azure-communication-chat-java 技能
构建实时聊天应用程序包括线程管理、消息传递、参与者和已读回执。技能概述azure-communication-chat-java 技能提供了Azure Communication Services Chat SDK for Java的完整使用指南。该技能帮助开发者构建实时聊天应用程序支持线程管理、消息发送和接收、参与者管理、已读回执和打字通知等功能。下载地址https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-communication-chat-java主要功能聊天线程管理: 创建、删除和管理聊天线程消息操作: 发送、接收、更新和删除消息参与者管理: 添加、删除和列出聊天参与者已读回执: 发送和跟踪消息已读状态打字通知: 发送打字指示器异步客户端: 支持异步操作提高性能触发条件在以下情况下应该调用此技能:需要构建Java聊天应用程序实现实时消息传递功能管理聊天线程和参与者实现已读回执和打字通知使用Azure Communication Services进行聊天开发核心概念类用途ChatClient创建/删除聊天线程获取线程客户端ChatThreadClient线程内操作消息、参与者、回执ChatParticipant聊天线程中的用户及显示名称ChatMessage消息内容、类型、发送者信息、时间戳ChatMessageReadReceipt每个参与者的已读回执跟踪安装方法dependency groupIdcom.azure/groupId artifactIdazure-communication-chat/artifactId version1.6.0/version /dependency使用示例示例1: 创建客户端import com.azure.communication.chat.ChatClient;import com.azure.communication.chat.ChatClientBuilder;import com.azure.communication.common.CommunicationTokenCredential;String endpoint https://resource.communication.azure.com;String userAccessToken user-access-token;CommunicationTokenCredential credential new CommunicationTokenCredential(userAccessToken);ChatClient chatClient new ChatClientBuilder().endpoint(endpoint).credential(credential).buildClient();示例2: 创建聊天线程import com.azure.communication.chat.models.*;import com.azure.communication.common.CommunicationUserIdentifier;import java.util.ArrayList;import java.util.List;ListChatParticipant participants new ArrayList();ChatParticipant participant1 new ChatParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier(user-id-1)).setDisplayName(Alice);ChatParticipant participant2 new ChatParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier(user-id-2)).setDisplayName(Bob);participants.add(participant1);participants.add(participant2);CreateChatThreadOptions options new CreateChatThreadOptions(Project Discussion).setParticipants(participants);CreateChatThreadResult result chatClient.createChatThread(options);String threadId result.getChatThread().getId();ChatThreadClient threadClient chatClient.getChatThreadClient(threadId);示例3: 发送和接收消息// 发送文本消息SendChatMessageOptions messageOptions new SendChatMessageOptions().setContent(Hello, team!).setSenderDisplayName(Alice).setType(ChatMessageType.TEXT);SendChatMessageResult sendResult threadClient.sendMessage(messageOptions);String messageId sendResult.getId();// 列出所有消息PagedIterableChatMessage messages threadClient.listMessages();for (ChatMessage message : messages) {System.out.println(ID: message.getId());System.out.println(Content: message.getContent().getMessage());System.out.println(Sender: message.getSenderDisplayName());}示例4: 管理参与者// 列出参与者PagedIterableChatParticipant participants threadClient.listParticipants();for (ChatParticipant participant : participants) {CommunicationUserIdentifier user (CommunicationUserIdentifier) participant.getCommunicationIdentifier();System.out.println(User: user.getId());System.out.println(Display Name: participant.getDisplayName());}// 添加参与者ListChatParticipant newParticipants new ArrayList();newParticipants.add(new ChatParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier(new-user-id)).setDisplayName(Charlie).setShareHistoryTime(OffsetDateTime.now().minusDays(7)));threadClient.addParticipants(newParticipants);// 删除参与者CommunicationUserIdentifier userToRemove new CommunicationUserIdentifier(user-id);threadClient.removeParticipant(userToRemove);示例5: 已读回执// 发送已读回执threadClient.sendReadReceipt(messageId);// 获取已读回执PagedIterableChatMessageReadReceipt receipts threadClient.listReadReceipts();for (ChatMessageReadReceipt receipt : receipts) {System.out.println(Message ID: receipt.getChatMessageId());System.out.println(Read by: receipt.getSenderCommunicationIdentifier());System.out.println(Read at: receipt.getReadOn());}消息类型类型描述TEXT常规聊天消息HTMLHTML格式消息TOPIC_UPDATED系统消息 - 主题已更改PARTICIPANT_ADDED系统消息 - 参与者已加入PARTICIPANT_REMOVED系统消息 - 参与者已离开最佳实践令牌管理: 用户令牌会过期使用CommunicationTokenRefreshOptions实现刷新逻辑分页: 对大型线程使用带maxPageSize的listMessages(options)共享历史: 添加参与者时设置shareHistoryTime控制消息可见性消息类型: 从用户消息中过滤系统消息PARTICIPANT_ADDED等已读回执: 仅在用户实际查看消息时发送回执环境变量AZURE_COMMUNICATION_ENDPOINThttps://resource.communication.azure.com AZURE_COMMUNICATION_USER_TOKENuser-access-token限制说明仅当任务明确符合上述范围时使用此技能不要将输出视为环境特定验证、测试或专家审查的替代品如果缺少所需的输入、权限、安全边界或成功标准请停止并寻求澄清
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

【外设】之大彩串口显示屏 2026/11/3 7:07:39

【外设】之大彩串口显示屏

大彩串口屏初步使用 1 .官网下载 STM32 屏幕 GUI 设计资料 http://www.gz-dc.com/category/typeid/4112 找到 STM32 Keil 工程,移植相关代码因项目而异进行移植,由于项目简单,本人只对用到的指令接口进行修改。 比如:注意事项&…

阅读更多 →
无法下载Windows系统iso文件 2026/11/3 12:09:35

无法下载Windows系统iso文件

当我遇到这个问题的时候,我打开了一个网站: 登录 然后我打算下载的时候: 突然那个官方的连接就可以下载了:

阅读更多 →
【清华代码熊】DeepSeek V4.1 Flash 后训练详解 2026/11/3 12:09:38

【清华代码熊】DeepSeek V4.1 Flash 后训练详解

📌 上期解析了 DeepSeek V4.1 Flash 模型架构改进,本期解析 DeepSeek V4.1 Flash 预训练/后训练技术: 🌟 预训练:45T 文本 多模态混合语料、直接训练 sparse attention(取消 DeepSeek V4 的 dense 冷启动&…

阅读更多 →
Shuffle-R1: Efficient RL framework for Multimodal Large Language Models via Data-centric Dynamic ... 2026/11/3 12:09:41

Shuffle-R1: Efficient RL framework for Multimodal Large Language Models via Data-centric Dynamic ...

文章主要内容和创新点 主要内容 本文聚焦于多模态大语言模型(MLLM)强化学习(RL)训练中的效率问题,提出了一个名为Shuffle-R1的框架。研究发现,当前RL训练存在两个关键缺陷: 优势值坍缩(Advantage Collapsing):批次中大多数优势值集中在零附近,导致有效梯度信号被淹…

阅读更多 →
PRvL: Quantifying the Capabilities and Risks of Large Language Models for PII Redaction 2026/11/4 1:25:31

PRvL: Quantifying the Capabilities and Risks of Large Language Models for PII Redaction

一、文章主要内容总结 本文聚焦于利用大型语言模型(LLMs)实现个人身份信息(PII)脱敏的研究,旨在解决传统脱敏方法(如基于规则的系统、领域特定命名实体识别(NER)模型)泛化能力差、跨格式/跨语境适应性弱的问题。 研究通过全面评估多种LLM架构(包括密集型LLM(D-LLM…

阅读更多 →
LLaVA-RE: Binary Image-Text Relevancy Evaluation with Multimodal Large Language Model 2026/11/4 3:51:11

LLaVA-RE: Binary Image-Text Relevancy Evaluation with Multimodal Large Language Model

文章主要内容和创新点 主要内容 本文聚焦于二进制图像-文本相关性评估任务(判断图像与文本“相关”或“不相关”),针对该任务中文本格式多样、相关性定义随场景变化等挑战,提出了基于多模态大语言模型(MLLM)的解决方案LLaVA-RE。 模型设计:LLaVA-RE基于LLaVA 1.5架构,…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞 ✉