hubot-genesys-cloud
Version:
Genesys Cloud adapter for Hubot
46 lines (31 loc) • 1.96 kB
text/coffeescript
Controller = require './framework/Controller.coffee'
module.exports = class VideoController extends Controller
: ['videoJoin', 'videoLeave']
:
joinVideo: (jid) ->
.debug 'video', 'startVideoChat', jid
type = (if jid.match(/@conference/) then 'groupchat' else 'chat')
stanza = new ltx.Element 'message', from:.jid.bare().toString(), to:jid, type:type
stanza.c 'video', xmlns:'orgspan:video', from:.jid.bare().toString(), type:'start'
.debug 'video', 'sending join', stanza.toString()
.send stanza
leaveVideo: (jid) ->
.debug 'video', 'leaveVideoChat', jid
type = (if jid.match(/@conference/) then 'groupchat' else 'chat')
stanza = new ltx.Element 'message', from:.jid.bare().toString(), to:jid, type: type
stanza.c 'video', xmlns:'orgspan:video', from:.jid.bare().toString(), type:'leave'
.debug 'video', 'sending leave', stanza.toString()
.send stanza
:
joinVideo: (stanza) -> stanza.is('message') and stanza.getChild('video', 'orgspan:video')?.attrs.type is 'start'
leaveVideo: (stanza) -> stanza.is('message') and stanza.getChild('video', 'orgspan:video')?.attrs.type is 'leave'
joinVideo: (stanza) ->
room = new JID(stanza.attrs.from).bare().toString()
from = new JID(stanza.getChild('video', 'orgspan:video').attrs.from).bare().toString()
.debug 'video', 'video join', from
'videoJoin', { from, room }
leaveVideo: (stanza) ->
room = new JID(stanza.attrs.from).bare().toString()
from = new JID(stanza.getChild('video', 'orgspan:video').attrs.from).bare().toString()
.debug 'video', 'video leave', from
'videoLeave', { from, room }