Changeset 125

Show
Ignore:
Timestamp:
10/31/07 17:13:32 (2 years ago)
Author:
omega
Message:

Détruit les salons quand un des deux interlocuteurs quitte

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • randomchat/randomchat.py

    r124 r125  
    9090                message.setFrom(room_jid+'/'+config.NICK_GUEST) 
    9191            con.send(message) 
     92 
     93    def destroy_room(self, room): 
     94        for jid in self.rooms[room]: 
     95            user = self.users[jid.getStripped()] 
     96            destroy = xmpp.Presence(to = jid, frm = room+'@'+self.jid+'/'+user['nick'], typ = 'unavailable', payload = [  
     97                xmpp.Node('x', attrs={'xmlns': xmpp.NS_MUC+'#user'}, payload = [  
     98                    xmpp.Node('item', attrs={'affiliation': 'none', 'role': 'none'}), 
     99                    xmpp.Node('destroy',payload = [  
     100                        xmpp.Node('reason', payload = ['Votre interlocuteur a quitté le salon'] )  
     101                    ]) 
     102                ]) 
     103            ]) 
     104            self.con.send(destroy) 
     105            del self.users[jid.getStripped()] 
     106        del self.rooms[room] 
    92107 
    93108 
     
    129144            self.rooms[room].append(frm) 
    130145        else: # if the user is already in, and we are this far, that means that we got a presence type!= available, we assume that he has left the chat 
    131             #TODO 
    132             pass 
     146            self.destroy_room(room) 
    133147         
    134148 
     
    152166        self.invite(room,jid1) 
    153167        self.invite(room,jid2) 
     168        #TODO add a timeout and destroy the room if neither of them has joined the room 
    154169 
    155170