client.message
See the Messaging guide for usage. All methods require a configured app key (websockets are ticket-authorized).
interface MuhkooMessageEvent<T = unknown> { subject: string; from: string; data: T;}
interface MessageSubscription { subject: string; unsubscribe(): void;}Methods
Section titled “Methods”subscribe(subject, handler)
Section titled “subscribe(subject, handler)”subscribe<T>(subject: string, handler: (e: MuhkooMessageEvent<T>) => void): MessageSubscriptionSubscribe to a pub/sub subject, or to your own user:<id> to receive direct
messages. Returns a handle with .unsubscribe().
publish(subject, data)
Section titled “publish(subject, data)”publish<T>(subject: string, data: T): Promise<void>Plaintext fan-out to everyone subscribed to subject.
send(target, payload)
Section titled “send(target, payload)”send<T>(target: string, payload: T): Promise<void>End-to-end-encrypted direct message. target must be user:<id>; throws
otherwise. Delivered in the recipient’s inbox space — they must be subscribed
and online.
disconnect()
Section titled “disconnect()”disconnect(): voidCloses every open connection (e.g. on logout).
Group channels
Section titled “Group channels”For group messaging with persisted history and space-scoped file sharing,
use client.space channels (createChannel /
joinChannel), which add a name registry, history, and keeper-admitted
membership.