Esempio n. 1
0
def listClients(session, request):
    """Dump list of clients to file specified in config"""
    def getClientInfo(client):
        output = ""
        if "user" in client.session:
            output += client.session["user"].getInfoString()
        else:
            output += "(Not logged in)"
        if "host" in client.session:
            output += "\t" + client.session["host"]
        return output
    clientData = Broadcast.get().mapClients(getClientInfo)
    toWrite = "\n".join(sorted(clientData))
    f = open(Settings.rosterfile,'w')
    f.write(toWrite)
    f.close()
    return str(ClientAction("rosterwritten",{"file":Settings.rosterfile}))
    pass
Esempio n. 2
0
 def connectionLost(self, reason):
     """Removes client from broadcast list once connection is closed"""
     print "lost client! %s"%(reason,)
     Broadcast.get().removeClient(self)
Esempio n. 3
0
 def connectionMade(self):
     """Store hostname on connection made, add to broadcast list"""
     self.session = {}
     self.session["host"] = self.transport.getHost().host
     self.buffer = ""
     Broadcast.get().addClient(self)
Esempio n. 4
0
def broadcast(session, request):
    """Send a message to all currently connected clients"""
    Broadcast.get().broadcast(json.dumps(request["data"]))
    return str(ClientAction("broadcasted",{}))