Skip to content

imConversationId

IM 会话 id 生成:稳定双人会话、多人会话、临时双人会话及片段安全化。

函数签名

typescript
function buildDeterministicTwoMemberConversationId(
  userId1: string,
  userId2: string,
): string

function newMultiMemberConversationId(): string

function sanitizeConversationIdSegment(raw: string): string

const EPHEMERAL_PEER_CONVERSATION_ID_PREFIX: string

function newEphemeralPeerConversationId(peerUserId: string): string

function normalizeImConversationId(id: unknown): string

function imConversationIdsEqual(
  a: string | null | undefined,
  b: string | null | undefined,
): boolean

使用场景

  • 后端创建/查找双人会话
  • 同一对端并存多条「临时」会话