Skip to content

Commit 065282e

Browse files
committed
Merge pull request #34 from gunblues/master
add function createRoom to MUC
2 parents b1e5cbd + f613050 commit 065282e

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

muc/strophe.muc.coffee

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

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

muc/strophe.muc.js

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)