UNPKG

@jsxc/jsxc

Version:

Real-time XMPP chat application with video calls, file transfer and encrypted communication

28 lines (22 loc) 742 B
import * as Namespace from '../../connection/xmpp/namespace'; import JID from '../../JID'; import { STATE } from './State'; import { $msg } from '../../vendor/Strophe'; export default class ChatStateConnection { constructor(private send) {} public sendPaused(to: JID, type: 'chat' | 'groupchat' = 'chat') { this.sendState(STATE.PAUSED, to, type); } public sendComposing(to: JID, type: 'chat' | 'groupchat' = 'chat') { this.sendState(STATE.COMPOSING, to, type); } private sendState(state: STATE, to: JID, type: 'chat' | 'groupchat' = 'chat') { let msg = $msg({ to: to.full, type, }).c(state, { xmlns: Namespace.get('CHATSTATES'), }); this.send(msg); } }