Changeset 162:8bffd58d7b6d for doc


Ignore:
Timestamp:
Jan 8, 2012, 9:26:06 AM (8 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Expose locked state of a room on join response with room created status.

When the presence in response to a join includes the room created status code
(201), the client should configure the room before it can be used. To enable
this, the locked state of the room is now exposed through the Room.locked
attribute.

Also, update example MUC client to deal with newly created, locked rooms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/examples/muc_client.tac

    r156 r162  
    1616
    1717from twisted.application import service
     18from twisted.python import log
    1819from twisted.words.protocols.jabber.jid import JID
    1920from wokkel.client import XMPPClient
     
    4243        """
    4344        Once authorized, join the room.
     45
     46        If the join action causes a new room to be created, the room will be
     47        locked until configured. Here we will just accept the default
     48        configuration by submitting an empty form using L{configure}, which
     49        usually results in a public non-persistent room.
     50
     51        Alternatively, you would use L{getConfiguration} to retrieve the
     52        configuration form, and then submit the filled in form with the
     53        required settings using L{configure}, possibly after presenting it to
     54        an end-user.
    4455        """
     56        def joinedRoom(room):
     57            if room.locked:
     58                # Just accept the default configuration.
     59                return self.configure(room.roomJID, {})
     60
    4561        MUCClient.connectionInitialized(self)
    46         self.join(self.roomJID, self.nick)
     62
     63        d = self.join(self.roomJID, self.nick)
     64        d.addCallback(joinedRoom)
     65        d.addCallback(lambda _: log.msg("Joined room"))
     66        d.addErrback(log.err, "Join failed")
     67
    4768
    4869    def receivedGroupChat(self, room, user, message):
Note: See TracChangeset for help on using the changeset viewer.