XMPP MUC多人聊天相关的一些stanza

阅读更多

 

 

 

参考: http://xmpp.org/extensions/xep-0045.html
 
创建room的stanza:
    from = '[email protected]/desktop'
    to = '[email protected]/firstwitch' >
  xmlns = 'http://jabber.org/protocol/muc' />
 
房间创建成功之后,client收到的stanza:
    from = '[email protected]/firstwitch'
    to = '[email protected]/desktop' >
  xmlns = 'http://jabber.org/protocol/muc#user' >
    affiliation = 'owner'
          role = 'moderator' />
    code = '110' />
    code = '201' />
 
 
创建成功之后对房间进行配置的stanza(根据自己需求提交响应的参数,下面的例子是配置room名称和members only):
一个set类型的iq,query里面的x元素的type为submit,然后里面的field为相关的配置项
from = '[email protected]/desktop'
    id = 'create2'
    to = '[email protected]'
    type = 'set' >
  xmlns = 'http://jabber.org/protocol/muc#owner' >
    xmlns = 'jabber:x:data' type = 'submit' >
      var = 'FORM_TYPE' >
        http://jabber.org/protocol/muc#roomconfig
     
      var = 'muc#roomconfig_roomname' >
        A Dark Cave
     
      var = 'muc#roomconfig_membersonly' >
        1
     
   
 
 
如果配置了room是members only,然后想要往该房间添加允许进入的member,使用下面的stanza:
一个set类型的iq,query里面的item元素表示要添加的member,可以添加多个item,即多个member,指定query的 affiliation属性 member即可
from = '[email protected]/desktop'
    id = 'member4'
    to = '[email protected]'
    type = 'set' >
  xmlns = 'http://jabber.org/protocol/muc#admin' >
    affiliation = 'none'
          jid = '[email protected]' />
    affiliation = 'member'
          jid = '[email protected]' />
 
 
如果想要禁言有个用户,可以通过下面的stanza( The element is OPTIONAL ):
from = '[email protected]/desktop'
    id = 'voice2'
    to = '[email protected]'
    type = 'set' >
  xmlns = 'http://jabber.org/protocol/muc#admin' >
    nick = 'thirdwitch'
          role = 'visitor' >
      Not so worthy after all!
   
 
离开房间:

    from='[email protected]/pda'
    to='[email protected]/thirdwitch'
    type='unavailable'/>

你可能感兴趣的:(xmpp,muc,stanza)