OverviewFilesCommitsIssuesDocsReleasesPeers

keet-cli / keet-core-4.14.4-pretty / lib / api / v2 / core / index.js

791 lines · javascript ref:
const e = require("scope-lock"),
  t = require("ready-resource"),
  s = require("b4a"),
  { KeetMethod: i } = require("../base"),
  o = {
    RoomChanged: 1,
    RoomChatChanged: 2,
    RoomDigestChanged: 3,
    RoomConfigChanged: 4,
    RoomMemberChanged: 5,
    RoomDeviceChanged: 6,
    RoomReactionsChanged: 7,
    RoomStatsChanged: 8,
    RoomJoinRequestsChanged: 9,
    PairingChanged: 10,
  },
  n = { Identity: 100, Pairing: 101, Lobby: 102, Chat: 103, Reactions: 104, Members: 105 },
  a = { Identity: 200, Pairing: 201, Lobby: 202, Chat: 203, Reactions: 204, Members: 205 }
class r {
  constructor(t) {
    ;((this.coreAPI = t),
      (this.keet = t.keet),
      (this.view = t.view),
      (this.rpc = t.rpc),
      (this.active = !1),
      (this._queue = []),
      (this._lock = new e({ debounce: !0 })))
  }
  _isTracking(e, t) {
    return !1
  }
  async _process(e, t) {}
  async _bump() {
    if (await this._lock.lock())
      try {
        const e = [...this._queue]
        this._queue = []
        for (const { type: t, event: s } of e) await this._process(t, s)
      } finally {
        this._lock.unlock()
      }
  }
  async bump() {
    try {
      await this._bump()
    } catch (e) {
      this.keet.onerror(e)
    }
  }
  dispatch(e, t) {
    this._isTracking(e, t) && (this._queue.push({ type: e, event: t }), this.bump())
  }
}
class h extends r {
  _isTracking(e, t) {
    switch (e) {
      case n.Identity:
      case a.Identity:
        return !0
      case o.RoomMemberChanged:
      case o.RoomDeviceChanged:
        return this.active && t.roomInfo.status.isPrivateProfile
      default:
        return !1
    }
  }
  async _process(e, t) {
    switch (e) {
      case n.Identity:
        return ((this.active = !0), this._onReset(t))
      case a.Identity:
        return ((this.active = !1), null)
      case o.RoomMemberChanged:
        return this._onRoomMemberChanged(t.value)
      case o.RoomDeviceChanged:
        return this._onRoomDeviceChanged(t.value)
      default:
        return null
    }
  }
  async _onReset({ clock: e } = {}) {
    this.keet.onlineBoot.opened || (await this.keet.onlineBoot.ready())
    const [t, s, i] = await Promise.all([
        this.keet.local.get("@local/identity"),
        this.keet.privateProfile.db.findOne("@keet/members"),
        this.keet.privateProfile.db.find("@keet/devices").toArray(),
      ]),
      o = t.status,
      n = s.key
    this.view.members.add(s)
    const a = []
    for (const e of i) (a.push(e.key), this.view.devices.add(e))
    ;(this.view.identity.onReset({ memberKey: n, deviceKeys: a, status: o }),
      e > 0 && this.rpc.coreHaveIdentity({ clock: e }))
  }
  _onRoomMemberChanged(e) {
    ;(this.view.members.add(e), this.rpc.coreIdentityMember({ memberKey: e.key }))
  }
  _onRoomDeviceChanged(e) {
    ;(this.view.devices.add(e), this.rpc.coreIdentityDevice({ deviceKey: e.key }))
  }
}
class c extends r {
  _isTracking(e, t) {
    switch (e) {
      case n.Pairing:
      case a.Pairing:
        return !0
      case o.RoomChanged:
      case o.RoomJoinRequestsChanged:
        return this.active && t.roomId === this.keet.privateProfile.id
      default:
        return !1
    }
  }
  _process(e, t) {
    switch (e) {
      case n.Pairing:
        return ((this.active = !0), this._onReset(t))
      case a.Pairing:
        return ((this.active = !1), null)
      case o.RoomChanged:
      case o.RoomJoinRequestsChanged:
        return this._onPrivateProfileChanged(t)
      default:
        return null
    }
  }
  _onPrivateProfileChanged(e) {
    return this._onReset({ clock: 0 })
  }
  async _onReset({ clock: e }) {
    this.keet.onlineBoot.opened || (await this.keet.onlineBoot.ready())
    const [t, s] = await Promise.all([
      this.keet.privateProfile.db.find("@keet-private-id/pending-invitations").toArray(),
      this.keet.privateProfile.db.find("@keet/join-requests").toArray(),
    ])
    ;(this.rpc.corePairingReset({ pendingInvitations: t, identityJoinRequests: s }),
      e > 0 && this.rpc.coreHavePairing({ clock: e }))
  }
}
class d extends r {
  constructor(e) {
    ;(super(e),
      (this._end = 0),
      (this._start = 0),
      (this._total = 0),
      (this._rooms = []),
      (this._roomMap = new Map()))
  }
  _isTracking(e, t) {
    switch (e) {
      case n.Lobby:
        return !0
      case o.RoomChanged:
        return this.active && !t.roomInfo.status.isPrivateProfile
      case o.RoomDigestChanged:
      case o.RoomConfigChanged:
      case o.RoomChatChanged:
        return this.active && this._roomMap.has(s.toString(t.roomKey, "hex"))
      default:
        return !1
    }
  }
  _process(e, t) {
    switch (e) {
      case n.Lobby:
        return ((this.active = !0), this._onReset(t))
      case a.Lobby:
        return ((this.active = !1), null)
      case o.RoomChanged:
        return this._onRoomActivity(t)
      case o.RoomDigestChanged:
        return this._onRoomDigestChanged(t)
      case o.RoomConfigChanged:
        return this._onRoomConfigChanged(t)
      case o.RoomChatChanged:
        return this._onRoomLastMessageChanged(t)
      default:
        return null
    }
  }
  _addRoom(e, t) {
    A(this.view, e, t)
  }
  _mapInfo(e, t) {
    return {
      visible: !(
        !1 === t?.status?.isActive ||
        e.status.isRemoved ||
        e.identity ||
        (e.dm && !e.config.title)
      ),
      timestamp: e.timestamps.latestChatMessage || e.timestamps.latestSync,
    }
  }
  async _resize(e) {
    if (this._rooms.length >= e) return
    let t = this._rooms.length || 1
    for (; t < e; ) t *= 2
    const i = this.keet.local.snapshot(),
      [o, n] = await Promise.all([
        i.find("@local/rooms-by-timestamp", { reverse: !0, limit: t }).toArray(),
        i.get("@local/stats"),
      ])
    ;(await i.close(), (this._total = n.activeRooms), (this._rooms = []), this._roomMap.clear())
    for (let e = 0; e < o.length; e++) {
      const t = o[e],
        i = s.toString(t.roomKey, "hex"),
        { timestamp: n } = this._mapInfo(t),
        a = { id: i, record: t, position: e, timestamp: n }
      ;(this._rooms.push(a), this._roomMap.set(i, a))
    }
  }
  _pushViewport() {
    const e = []
    for (let t = this._start; t < Math.min(this._end, this._rooms.length); t++) {
      const { id: s, record: i } = this._rooms[t]
      ;(this._addRoom(s, i), e.push(i.roomKey))
    }
    this.rpc.coreLobbyReset({ keys: e, start: this._start, end: this._end, total: this._total })
  }
  async _onReset({ clock: e, start: t, end: s }) {
    ;((this._start = t),
      (this._end = s),
      await this._resize(s),
      this._pushViewport(),
      e > 0 && this.rpc.coreHaveLobby({ clock: e }))
  }
  async _onRoomActivity({ roomKey: e, roomInfo: t }) {
    const i = s.toString(e, "hex"),
      o = this.keet.local.snapshot(),
      [n, a] = await Promise.all([
        o.get("@local/stats"),
        o.get("@local/room-preferences", { roomKey: e }),
      ])
    ;(await o.close(), (this._total = n.activeRooms))
    const { visible: r, timestamp: h } = this._mapInfo(t, a),
      c = t,
      d = this._roomMap.get(i)
    if (!d && !r) return
    if (d && r && h <= d.timestamp) return
    const m = d?.position ?? -1
    let g = -1
    if (r) {
      let e = 0,
        t = this._rooms.length
      for (; e < t; ) {
        const s = (e + t) >>> 1
        this._rooms[s].timestamp > h ? (e = s + 1) : (t = s)
      }
      ;((g = e), d && g > m && g--)
    }
    if (m !== g) {
      if (g < 0) {
        for (let e = m, t = this._rooms.length - 1; e < t; e++)
          ((this._rooms[e] = this._rooms[e + 1]), (this._rooms[e].position = e))
        ;(this._rooms.pop(), this._roomMap.delete(i))
      } else if (m < 0) {
        this._rooms.push(null)
        for (let e = this._rooms.length - 1; e > g; e--)
          ((this._rooms[e] = this._rooms[e - 1]), (this._rooms[e].position = e))
        const e = { id: i, record: c, position: g, timestamp: h }
        ;((this._rooms[g] = e), this._roomMap.set(i, e))
      } else if (m > g) {
        for (let e = m; e > g; e--)
          ((this._rooms[e] = this._rooms[e - 1]), (this._rooms[e].position = e))
        ;((this._rooms[g] = d), (d.position = g), (d.record = c), (d.timestamp = h))
      } else {
        for (let e = m; e < g; e++)
          ((this._rooms[e] = this._rooms[e + 1]), (this._rooms[e].position = e))
        ;((this._rooms[g] = d), (d.position = g), (d.record = c), (d.timestamp = h))
      }
      ;((m >= 0 && m < this._end) || (g >= 0 && g < this._end)) && this._pushViewport()
    } else d && ((d.record = c), (d.timestamp = h))
  }
  _onRoomDigestChanged({ roomKey: e, value: t }) {
    const i = s.toString(e, "hex")
    this.view.roomInfo.onDigestChanged({ id: i, digest: t })
  }
  _onRoomConfigChanged({ roomKey: e, value: t }) {
    const i = s.toString(e, "hex")
    this.view.roomInfo.onConfigChanged({ id: i, config: t })
  }
  _onRoomLastMessageChanged({ roomKey: e, roomInfo: t }) {
    const i = s.toString(e, "hex")
    U(this.view, i, t)
  }
}
class m extends r {
  constructor(e) {
    ;(super(e),
      (this.roomKey = null),
      (this._roomId = null),
      (this.start = 0),
      (this.size = 0),
      (this.isBottom = !1),
      (this._chatLength = -1),
      (this._viewportIds = []),
      (this._memberMessages = new Map()))
  }
  _isTracking(e, t) {
    let i = !1
    switch (e) {
      case n.Chat:
      case a.Chat:
        i = !0
        break
      case o.RoomDigestChanged:
      case o.RoomConfigChanged:
        i = this.active && this.roomKey && s.equals(t.roomKey, this.roomKey)
        break
      case o.RoomChatChanged:
      case o.RoomReactionsChanged:
      case o.RoomMemberChanged:
        i = this.roomKey && s.equals(t.roomKey, this.roomKey)
        break
      default:
        i = !1
    }
    return i
  }
  _process(e, t) {
    switch (e) {
      case n.Chat:
        return ((this._chatLength = -1), this._onActivate(t))
      case a.Chat:
        return this._onDeactivate(t)
      case o.RoomDigestChanged:
        return this._onRoomDigestChanged(t)
      case o.RoomConfigChanged:
        return this._onRoomConfigChanged(t)
      case o.RoomChatChanged:
        return this._onRoomChatChanged(t)
      case o.RoomReactionsChanged:
        return this._onRoomReactionsChanged(t)
      case o.RoomMemberChanged:
        return this._onRoomMemberChanged(t)
      default:
        return null
    }
  }
  async _pushMessage(e, t) {
    const [s, i] = await Promise.all([
        e.get("@keet/reaction-digests", { id: t.id }),
        e.get("@keet/devices", { key: t.oplog.key }),
      ]),
      o = await e.get("@keet/members", { key: i.memberKey })
    return this._pushMessageDirect(t, s, i, o)
  }
  _pushMessageDirect(e, t, i, o) {
    const n = s.toString(o.key, "hex"),
      a = `${s.toString(e.oplog.key, "hex")}-${e.oplog.seq}`
    ;(this._memberMessages.has(n) || this._memberMessages.set(n, []),
      this._memberMessages.get(n).push(e.oplog),
      t && this.view.reactions.add(t, { cacheId: a }),
      this.view.members.add(o))
    const r = { chat: L(e), memberKey: o.key, role: o.status }
    return (this.view.messageInfo.onAdd(r, { cacheId: a }), e.oplog)
  }
  async _pushMessages(e, t, s) {
    this._memberMessages.clear()
    const i = []
    for await (const s of e.find("@keet/chat", t)) i.push(this._pushMessage(e, s))
    const o = await Promise.all(i)
    ;((this._viewportIds = o), this._emitReset(s))
  }
  _emitReset(e) {
    this.view.chat.onReset({
      ids: this._viewportIds,
      roomKey: this.roomKey,
      start: this.start,
      size: this.size,
      total: e,
      isBottom: this.isBottom,
    })
  }
  async _pushViewport() {
    const e = this.keet.internalOpenExistingRoom(this.roomKey),
      t = e.db.snapshot()
    try {
      const e = await t.get("@keet/threads", { id: 0 })
      this._chatLength = e.count
      const s = Math.max(this.isBottom ? this._chatLength - this.size : this.start, 0),
        i = Math.min(this.isBottom ? this._chatLength : this.start + this.size, this._chatLength)
      await this._pushMessages(
        t,
        { gte: { id: { thread: 0, index: s } }, lt: { id: { thread: 0, index: i } } },
        this._chatLength,
      )
    } finally {
      ;(t && (await t.close()), this.keet.internalReleaseRoom(e))
    }
  }
  async _onActivate({ clock: e, roomKey: t, start: i, size: o, isBottom: n }) {
    ;(this.roomKey &&
      !s.equals(this.roomKey, t) &&
      (await this.keet.deactivateRoom(this.roomKey), this.view.rooms.unref(this._roomId)),
      (this.roomKey = t),
      (this._roomId = s.toString(t, "hex")),
      (this.start = i),
      (this.size = o),
      (this.isBottom = n),
      this.view.rooms.ref(this._roomId),
      await this.keet.activateRoom(t),
      (this.active = !0))
    const a = await this.keet.local.get("@local/rooms", { roomKey: t })
    ;(A(this.view, this._roomId, a),
      await this._pushViewport(),
      e > 0 && this.rpc.coreHaveChat({ clock: e }))
  }
  async _onDeactivate() {
    ;(this.roomKey &&
      (await this.keet.deactivateRoom(this.roomKey), this.view.rooms.unref(this._roomId)),
      (this.roomKey = null),
      (this._roomId = null),
      (this.active = !1))
  }
  _onRoomDigestChanged({ value: e }) {
    this.view.roomInfo.onDigestChanged({ id: this._roomId, digest: e })
  }
  _onRoomConfigChanged({ value: e }) {
    this.view.roomInfo.onConfigChanged({ id: this._roomId, config: e })
  }
  _isInViewport(e) {
    const t = this.isBottom ? this._chatLength - this.size : this.start,
      s = this.isBottom ? this._chatLength : this.start + this.size
    return e >= t && e < s
  }
  _onRoomChatChanged(e) {
    const { message: t, reactions: s, device: i, member: o } = e.value,
      n = t.id.index
    if (n >= this._chatLength) {
      if (this.isBottom) {
        const e = this._pushMessageDirect(t, s, i, o)
        for (
          this._viewportIds.push(e), this._chatLength = n + 1;
          this._viewportIds.length > this.size;
        )
          this._viewportIds.shift()
        this._emitReset(this._chatLength)
      }
    } else this._isInViewport(n) && this.view.messageInfo.onChatChanged({ chat: L(t) })
  }
  _onRoomReactionsChanged({ value: { id: e, reactions: t } }) {
    this._isInViewport(t.id.index) &&
      this.view.messageInfo.onReactionsChanged({ id: e, reactions: t })
  }
  _onRoomMemberChanged({ value: e }) {
    const t = s.toString(e.key, "hex"),
      i = this._memberMessages.get(t)
    i &&
      0 !== i.length &&
      (this.view.members.add(e),
      this.view.messageInfo.onRoleChanged({ ids: i, role: e.status }),
      this.view.messageInfo.onMemberChanged({ ids: i, memberKey: e.key }))
  }
}
class g extends r {}
class u extends i {
  async _run() {
    return { roomKey: await this.keet.createRoom(this.req) }
  }
}
class l extends i {
  _run() {
    return this.keet.leaveRoom(this.req.roomKey)
  }
}
class p extends i {
  _run() {
    return this.keet.activateRoom(this.req.roomKey)
  }
}
class C extends i {
  _run() {
    return this.keet.deactivateRoom(this.req.roomKey)
  }
}
class _ extends i {
  async _run() {
    const e = this.req.permissions
    return {
      invitation: await this.keet.createRoomInvitation(this.req.roomKey, {
        requiresConfirmation: !!e?.requiresConfirmation,
        canModerate: !!e?.canModerate,
        canAdmin: !!e?.canAdmin,
        readOnly: !!e?.isReadOnly,
        expiration: this.req.expiration,
      }),
    }
  }
}
class R extends i {
  async _run() {
    return { invitation: await this.keet.createIdentityInvitation() }
  }
}
class b extends i {
  _run() {
    return this.keet.updateProfile(this.req)
  }
}
class y extends i {
  _run() {
    return this.req.isIdentity
      ? this.keet.startPairingIdentity(this.req.invitation)
      : this.keet.startPairingRoom(this.req.invitation)
  }
}
class k extends i {
  _run() {
    return this.keet.acceptJoinRequest(this.req.roomKey, this.req.request.deviceKey)
  }
}
class v extends i {
  _run() {
    return this.keet.rejectJoinRequest(this.req.roomKey, this.req.request.deviceKey)
  }
}
class f extends i {
  _run() {
    return this.keet.stopPairing(this.req.id)
  }
}
class w extends i {
  _run() {
    return this.keet.dispatch(this.req.roomKey, "@keet/update-room-config", this.req)
  }
}
class I extends i {
  _run() {}
}
class M extends i {
  _run() {}
}
class q extends i {
  async _run() {
    await this.keet.dispatch(this.req.roomKey, "@keet/add-chat-message", {
      message: this.req.message,
    })
  }
}
class K extends i {
  _run() {
    return this.keet.dispatch(this.req.roomKey, "@keet/update-chat-message", {
      oplog: this.req.id,
      message: this.req.message,
    })
  }
}
class P extends i {
  _run() {
    return this.keet.dispatch(this.req.roomKey, "@keet/remove-chat-message", { oplog: this.req.id })
  }
}
class x extends i {
  _run() {
    return this.keet.dispatch(this.req.roomKey, "@keet/add-reaction", {
      oplog: this.req.id,
      reaction: this.req.reaction,
    })
  }
}
class T extends i {
  _run() {
    return this.keet.dispatch(this.req.roomKey, "@keet/remove-reaction", {
      oplog: this.req.id,
      reaction: this.req.reaction,
    })
  }
}
function L(e) {
  return {
    id: e.oplog,
    clock: e.clock,
    timestamps: { sent: e.timestamp, edited: e.editedAt },
    status: e.status,
    message: e.message,
    event: e.event,
  }
}
function D(e) {
  return { member: e.selfMember?.status, device: e.status }
}
function A(e, t, s) {
  let i = null
  s.lastMessage &&
    (e.members.add(s.lastMember),
    (i = e.messageInfo.onAdd({
      chat: L(s.lastMessage),
      memberKey: s.lastMember.key,
      role: s.lastMember.status,
    })))
  const o = { id: s.roomKey, digest: s.digest, config: s.config, messageId: i?.id, role: D(s) }
  e.roomInfo.onAdd(o, { cacheId: t })
}
function U(e, t, s) {
  if (!s.lastMessage) return
  e.members.add(s.lastMember)
  const i = e.messageInfo.onAdd({
    chat: L(s.lastMessage),
    memberKey: s.lastMember.key,
    role: s.lastMember.status,
  })
  e.roomInfo.onLastMessageChanged({ id: t, messageId: i.id })
}
module.exports = class extends t {
  constructor(e) {
    ;(super(),
      (this.backend = e),
      (this.keet = this.backend.keet),
      (this.rpc = this.backend.rpc),
      (this.view = this.backend.view),
      (this.identityTracker = new h(this)),
      (this.pairingTracker = new c(this)),
      (this.lobbyTracker = new d(this)),
      (this.chatTracker = new m(this)),
      (this.memberTracker = new g(this)),
      (this.trackers = [
        this.identityTracker,
        this.pairingTracker,
        this.lobbyTracker,
        this.chatTracker,
        this.memberTracker,
      ]),
      this.rpc.onCoreCreateRoom(this.onCreateRoom.bind(this)),
      this.rpc.onCoreActivateRoom(this.onActivateRoom.bind(this)),
      this.rpc.onCoreDeactivateRoom(this.onDeactivateRoom.bind(this)),
      this.rpc.onCoreLeaveRoom(this.onLeaveRoom.bind(this)),
      this.rpc.onCoreUpdateRoomConfig(this.onUpdateRoomConfig.bind(this)),
      this.rpc.onCoreUpdateRoomSettings(this.onUpdateRoomSettings.bind(this)),
      this.rpc.onCoreUpdateRoomStatus(this.onUpdateRoomStatus.bind(this)),
      this.rpc.onCoreUpdateProfile(this.onUpdateProfile.bind(this)),
      this.rpc.onCoreStartPairing(this.onStartPairing.bind(this)),
      this.rpc.onCoreCreateRoomInvitation(this.onCreateRoomInvitation.bind(this)),
      this.rpc.onCoreCreateIdentityInvitation(this.onCreateIdentityInvitation.bind(this)),
      this.rpc.onCoreAcceptJoinRequest(this.onAcceptJoinRequest.bind(this)),
      this.rpc.onCoreRejectJoinRequest(this.onRejectJoinRequest.bind(this)),
      this.rpc.onCoreStopPairing(this.onStopPairing.bind(this)),
      this.rpc.onCoreAddChatMessage(this.onAddChatMessage.bind(this)),
      this.rpc.onCoreEditChatMessage(this.onEditChatMessage.bind(this)),
      this.rpc.onCoreRemoveChatMessage(this.onRemoveChatMessage.bind(this)),
      this.rpc.onCoreAddChatReaction(this.onAddChatReaction.bind(this)),
      this.rpc.onCoreRemoveChatReaction(this.onRemoveChatReaction.bind(this)),
      this.rpc.onCoreWantLobby(this.onWantLobby.bind(this)),
      this.rpc.onCoreUnwantLobby(this.onUnwantLobby.bind(this)),
      this.rpc.onCoreWantIdentity(this.onWantIdentity.bind(this)),
      this.rpc.onCoreUnwantIdentity(this.onUnwantIdentity.bind(this)),
      this.rpc.onCoreWantPairing(this.onWantPairing.bind(this)),
      this.rpc.onCoreUnwantPairing(this.onUnwantPairing.bind(this)),
      this.rpc.onCoreWantChat(this.onWantChat.bind(this)),
      this.rpc.onCoreUnwantChat(this.onUnwantChat.bind(this)),
      this.rpc.onCoreWantMembers(this.onWantMembers.bind(this)),
      this.rpc.onCoreUnwantMembers(this.onUnwantMembers.bind(this)))
  }
  async boot() {
    return {}
  }
  onPairingChanged() {
    this._dispatch(o.PairingChanged, null)
  }
  onRoomChanged(e) {
    ;(this.identityTracker.dispatch(o.RoomChanged, e),
      this.pairingTracker.dispatch(o.RoomChanged, e),
      this.lobbyTracker.dispatch(o.RoomChanged, e),
      this.chatTracker.dispatch(o.RoomChanged, e))
  }
  onRoomChatChanged(e) {
    ;(this.chatTracker.dispatch(o.RoomChatChanged, e),
      this.lobbyTracker.dispatch(o.RoomChatChanged, e))
  }
  onRoomDigestChanged(e) {
    ;(this.lobbyTracker.dispatch(o.RoomDigestChanged, e),
      this.chatTracker.dispatch(o.RoomDigestChanged, e))
  }
  onRoomMemberChanged(e) {
    ;(this.identityTracker.dispatch(o.RoomMemberChanged, e),
      this.chatTracker.dispatch(o.RoomMemberChanged, e))
  }
  onRoomDeviceChanged(e) {
    this.identityTracker.dispatch(o.RoomDeviceChanged, e)
  }
  onRoomConfigChanged(e) {
    ;(this.lobbyTracker.dispatch(o.RoomConfigChanged, e),
      this.chatTracker.dispatch(o.RoomConfigChanged, e))
  }
  onRoomReactionsChanged(e) {
    this.chatTracker.dispatch(o.RoomReactionsChanged, e)
  }
  onRoomStatsChanged(e) {
    this.chatTracker.dispatch(o.RoomStatsChanged, e)
  }
  onRoomJoinRequestsChanged(e) {
    this.pairingTracker.dispatch(o.RoomJoinRequestsChanged, e)
  }
  onWantIdentity(e) {
    this.identityTracker.dispatch(n.Identity, e)
  }
  onUnwantIdentity(e) {
    this.identityTracker.dispatch(a.Identity, e)
  }
  onWantPairing(e) {
    this.pairingTracker.dispatch(n.Pairing, e)
  }
  onUnwantPairing(e) {
    this.pairingTracker.dispatch(a.Pairing, e)
  }
  onWantLobby(e) {
    this.lobbyTracker.dispatch(n.Lobby, e)
  }
  onUnwantLobby(e) {
    this.lobbyTracker.dispatch(a.Lobby, e)
  }
  onWantChat(e) {
    this.chatTracker.dispatch(n.Chat, e)
  }
  onUnwantChat(e) {
    this.chatTracker.dispatch(a.Chat, e)
  }
  onWantReactions(e) {
    this.reactionTracker.dispatch(n.Reactions, e)
  }
  onUnwantReactions(e) {
    this.reactionTracker.dispatch(a.Reactions, e)
  }
  onWantMembers(e) {
    this.memberTracker.dispatch(n.Members, e)
  }
  onUnwantMembers(e) {
    this.memberTracker.dispatch(a.Members, e)
  }
  onCreateRoom(e) {
    return u.run(this.backend, e)
  }
  onLeaveRoom(e) {
    return l.run(this.backend, e)
  }
  onActivateRoom(e) {
    return p.run(this.backend, e)
  }
  onDeactivateRoom(e) {
    return C.run(this.backend, e)
  }
  onUpdateRoomConfig(e) {
    return w.run(this.backend, e)
  }
  onUpdateRoomSettings(e) {
    return I.run(this.backend, e)
  }
  onUpdateRoomStatus(e) {
    return M.run(this.backend, e)
  }
  onUpdateProfile(e) {
    return b.run(this.backend, e)
  }
  onStartPairing(e) {
    return y.run(this.backend, e)
  }
  onCreateRoomInvitation(e) {
    return _.run(this.backend, e)
  }
  onCreateIdentityInvitation(e) {
    return R.run(this.backend, e)
  }
  onAcceptJoinRequest(e) {
    return k.run(this.backend, e)
  }
  onRejectJoinRequest(e) {
    return v.run(this.backend, e)
  }
  onStopPairing(e) {
    return f.run(this.backend, e)
  }
  onAddChatMessage(e) {
    return q.run(this.backend, e)
  }
  onEditChatMessage(e) {
    return K.run(this.backend, e)
  }
  onRemoveChatMessage(e) {
    return P.run(this.backend, e)
  }
  onAddChatReaction(e) {
    return x.run(this.backend, e)
  }
  onRemoveChatReaction(e) {
    return T.run(this.backend, e)
  }
}