Skip to content

Commit 5d26a57

Browse files
gunbluesgunblues
authored andcommitted
add function createRoom to MUC
1 parent 5e65dda commit 5d26a57

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

muc/strophe.muc.coffee

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,27 @@ Strophe.addConnectionPlugin 'muc',
323323
.c("x", xmlns: "jabber:x:data", type: "submit")
324324
@_connection.sendIQ roomiq.tree(), success_cb, error_cb
325325

326+
###Function
327+
Parameters:
328+
(String) room - The multi-user chat room name.
329+
(Object) config - the configuration. ex: {"muc#roomconfig_publicroom": "0", "muc#roomconfig_persistentroom": "1"}
330+
Returns:
331+
id - the unique id used to create the chat room.
332+
###
333+
createRoom: (room, config, success_cb, error_cb) ->
334+
roomiq = $iq(
335+
to: room
336+
type: "set" )
337+
.c("query", xmlns: Strophe.NS.MUC_OWNER)
338+
.c("x", xmlns: "jabber:x:data", type: "submit")
339+
340+
# Owner submits configuration form
341+
roomiq.c('field', { 'var': 'FORM_TYPE' }).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
342+
343+
roomiq.c('field', { 'var': k}).c('value').t(v).up().up() for own k, v of config
344+
345+
@_connection.sendIQ roomiq.tree(), success_cb, error_cb
346+
326347
###Function
327348
Set the topic of the chat room.
328349
Parameters:

muc/strophe.muc.js

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)