def send(self, mmp, psyc): # route to the right host target = mmp.get_target() if not target.startswith("psyc://") and ( target.startswith("@") or target.startswith("~")): target = "psyc://" + self.DEFAULT_HOST() + "/" + target mmp._set("_target", target) # print ">>>", target # print "mmp :", mmp.get_state() # print "psyc:", psyc.get_state() # print "mc :", psyc.get_mc() # print "text:", psyc.get_text() # #print "get_host(" + unl + "):", get_host(unl) # print "---" host = gethostbyname(get_host(target)) if not self.clients.has_key(host): ## print "Error: we are not yet connected to ", host self.connect(host) # put the current packet in a queue, # connect and auth before sending else: # wait... we have to register before sending? # print "sending..." # print "client is:", self.clients[hostpart] self.clients[host].sendPacket(mmp, psyc)
def connect(self, uni = '', port = 4404): # eigentlich sollte port via uni if uni == '': uni = self.config.get("main", "uni") print uni host = gethostbyname(get_host(uni)) # hier muessen die auch noch richtig rein if not self.clients.has_key(host): # not sure if this works... # das hier muss umgestrickt werden # irgendwie per callback setzen PSYCConnector(self, host, port)
def DEFAULT_HOST(self): return get_host(self.ME())