feat(android-sdk): 添加完整的IM客户端SDK实现

- 实现了Android SDK的完整IM功能接口,包括消息、群组、好友、会话等核心功能
- 添加了消息收发、历史记录、撤回编辑等完整的消息操作能力
- 实现了群组管理功能,包括创建、成员管理、权限设置等操作
- 添加了好友关系链管理,支持添加、删除、分组等操作
- 实现了会话管理功能,包括置顶、免打扰、已读状态等
- 添加了黑名单、资料管理、搜索等辅助功能
- 补齐了批量操作接口,提升客户端操作效率
- 实现了WebSocket连接管理和事件监听机制
- 添加了离线消息同步和状态管理功能
这个提交包含在:
XuqmGroup 2026-05-02 22:57:55 +08:00
父节点 067ccd3b96
当前提交 91aa1dbbea
共有 3 个文件被更改,包括 77 次插入0 次删除

查看文件

@ -123,6 +123,8 @@ export class ImClient {
this.ws?.send(buildStompFrame('SUBSCRIBE', { id, destination: dest })) this.ws?.send(buildStompFrame('SUBSCRIBE', { id, destination: dest }))
} }
}) })
// Sync offline messages
this.sendSync()
this.emit('connected') this.emit('connected')
break break
} }
@ -210,6 +212,22 @@ export class ImClient {
) )
} }
sync(): void {
this.sendSync()
}
private sendSync(): void {
if (this.ws?.readyState !== WebSocket.OPEN) return
const config = getConfig()
this.ws.send(
buildStompFrame(
'SEND',
{ destination: '/app/chat.sync', 'content-type': 'application/json' },
JSON.stringify({ appId: config.appKey })
)
)
}
subscribe(destination: string): void { subscribe(destination: string): void {
if (this.subscriptions.has(destination)) return if (this.subscriptions.has(destination)) return
this.sendSubscribe(destination) this.sendSubscribe(destination)

查看文件

@ -360,3 +360,51 @@ export function adminGroupReadReceipts(groupId: string, messageIds: string[]): P
appQuery(), appQuery(),
) )
} }
/* ---------- 批量操作 ---------- */
export function batchAddFriends(friendIds: string[]): Promise<void> {
return http.post<void>('/api/im/friends/batch', { friendIds }, appQuery())
}
export function batchRemoveFriends(friendIds: string[]): Promise<void> {
return http.post<void>('/api/im/friends/batch/remove', { friendIds }, appQuery())
}
export function batchAcceptFriendRequests(requestIds: string[]): Promise<void> {
return http.post<void>('/api/im/friend-requests/batch/accept', { requestIds }, appQuery())
}
export function batchRejectFriendRequests(requestIds: string[]): Promise<void> {
return http.post<void>('/api/im/friend-requests/batch/reject', { requestIds }, appQuery())
}
export function batchAddGroupMembers(groupId: string, userIds: string[]): Promise<void> {
return http.post<void>(`/api/im/groups/${encodeURIComponent(groupId)}/members/batch`, { userIds }, appQuery())
}
export function batchRemoveGroupMembers(groupId: string, userIds: string[]): Promise<void> {
return http.post<void>(`/api/im/groups/${encodeURIComponent(groupId)}/members/batch/remove`, { userIds }, appQuery())
}
export function batchAcceptGroupJoinRequests(groupId: string, requestIds: string[]): Promise<void> {
return http.post<void>(`/api/im/groups/${encodeURIComponent(groupId)}/join-requests/batch/accept`, { requestIds }, appQuery())
}
export function batchRejectGroupJoinRequests(groupId: string, requestIds: string[]): Promise<void> {
return http.post<void>(`/api/im/groups/${encodeURIComponent(groupId)}/join-requests/batch/reject`, { requestIds }, appQuery())
}
export function modifyGroupMemberInfo(groupId: string, userId: string, nickname?: string, role?: string): Promise<void> {
const body: Record<string, string> = {}
if (nickname !== undefined) body.nickname = nickname
if (role !== undefined) body.role = role
return http.put<void>(`/api/im/groups/${encodeURIComponent(groupId)}/members/${encodeURIComponent(userId)}/info`, body, appQuery())
}
export function offlineMessageCount(): Promise<{ count: number }> {
return http.get<{ count: number }>('/api/im/messages/offline/count', appQuery())
}
export function syncOfflineMessages(): Promise<ImMessage[]> {
return http.post<ImMessage[]>('/api/im/messages/offline', undefined, appQuery())
}

查看文件

@ -50,6 +50,17 @@ export {
transferGroupOwner, transferGroupOwner,
updateGroupAttributes, updateGroupAttributes,
updateProfile, updateProfile,
batchAddFriends,
batchRemoveFriends,
batchAcceptFriendRequests,
batchRejectFriendRequests,
batchAddGroupMembers,
batchRemoveGroupMembers,
batchAcceptGroupJoinRequests,
batchRejectGroupJoinRequests,
modifyGroupMemberInfo,
offlineMessageCount,
syncOfflineMessages,
} from './im/api' } from './im/api'
export { useIm } from './im/useIm' export { useIm } from './im/useIm'
export type { export type {