コード例 #1
0
ファイル: __init__.py プロジェクト: rogovvladimir/twilix
 def leave_room(self, presence, room_jid, nickname):
     """
     Sends 'unavailable'-type presence which leaves client from the room.
     Fails if user not in room.
     
     :param room_jid: JID of room-conference
     :param nickname: string-type client's nickname in conference
     
     """
     reciever = internJID(room_jid)
     
     assert reciever.bare() in self.roster, 'not in room'
     
     reciever.resource = nickname
     
     presence = MyElement.makeFromElement(presence)
     presence = Presence.createFromElement(presence)
     
     presence.to = reciever
     presence.from_ = self.dispatcher.myjid
     presence.type_ = 'unavailable'
     
     msg = ConnectPresence(parent=presence)
     
     self.dispatcher.send(msg.parent)
     
     del self.roster[reciever.bare()]
コード例 #2
0
ファイル: __init__.py プロジェクト: rogovvladimir/twilix
    def enter_room(self, presence, room_jid, nickname):
        """
        Sends 'available'-type presence which allows client to enter the room.
        Fails if user already in room.
        
        :param room_jid: JID of room-conference
        :param nickname: string-type client's nickname in conference
        :param status: string-type client's status message
        
        """
        reciever = internJID(room_jid)
        
        assert reciever.bare() not in self.roster, 'already in room'
        
        reciever.resource = nickname
 
        presence = MyElement.makeFromElement(presence)
        presence = Presence.createFromElement(presence)
 
        presence.to = reciever
        presence.from_ = self.dispatcher.myjid
        
        msg = ConnectPresence(parent=presence)
        
        self.roster[reciever.bare()] = []
        
        self.dispatcher.send(msg.parent)
コード例 #3
0
ファイル: __init__.py プロジェクト: rogovvladimir/twilix
    def leave_room(self, presence, room_jid, nickname):
        """
        Sends 'unavailable'-type presence which leaves client from the room.
        Fails if user not in room.
        
        :param room_jid: JID of room-conference
        :param nickname: string-type client's nickname in conference
        
        """
        reciever = internJID(room_jid)

        assert reciever.bare() in self.roster, 'not in room'

        reciever.resource = nickname

        presence = MyElement.makeFromElement(presence)
        presence = Presence.createFromElement(presence)

        presence.to = reciever
        presence.from_ = self.dispatcher.myjid
        presence.type_ = 'unavailable'

        msg = ConnectPresence(parent=presence)

        self.dispatcher.send(msg.parent)

        del self.roster[reciever.bare()]
コード例 #4
0
ファイル: __init__.py プロジェクト: rogovvladimir/twilix
    def enter_room(self, presence, room_jid, nickname):
        """
        Sends 'available'-type presence which allows client to enter the room.
        Fails if user already in room.
        
        :param room_jid: JID of room-conference
        :param nickname: string-type client's nickname in conference
        :param status: string-type client's status message
        
        """
        reciever = internJID(room_jid)

        assert reciever.bare() not in self.roster, 'already in room'

        reciever.resource = nickname

        presence = MyElement.makeFromElement(presence)
        presence = Presence.createFromElement(presence)

        presence.to = reciever
        presence.from_ = self.dispatcher.myjid

        msg = ConnectPresence(parent=presence)

        self.roster[reciever.bare()] = []

        self.dispatcher.send(msg.parent)
コード例 #5
0
ファイル: fields.py プロジェクト: xamvz/weather
 def clean_set(self, value):
     if value is None:
         return EmptyElement()
     r = MyElement((self.uri, self.xmlnode))
     r.content = unicode(value)
     return r
コード例 #6
0
ファイル: fields.py プロジェクト: xamvz/weather
 def clean_set(self, value):
     if value is not None:
         r = MyElement((None, self.xmlnode))
         r.content = base64.b64encode(unicode(value))
         return r