From: DJ A. <dj....@po...> - 2001-11-07 11:29:20
|
On Tue, Nov 06, 2001 at 06:58:29PM -0700, Brian Lalor wrote: > Hey DJ and Mallum! > > Just checked out jabberpy from CVS; I'd like to play with the component > class a bit. Can you guys throw out a snippet from jabber.xml and a bit > of code to drive the Component class with? Nothing fancy, but enough that > it will compile. :-) Hi Brian Here's a simple script and XML that I used to test my fiddlings The XML ------- <service id="comptest.localhost"> <accept> <ip>localhost</ip> <secret>secret</secret> <port>5707</port> </accept> </service> The script ---------- #!/usr/bin/python import jabber import sys Server = 'localhost' def messageCB(con, msg): print msg.getBody() con = jabber.Component(host='localhost', port=5707,debug=1,log='log') try: con.connect() except IOError, e: print "Couldn't connect: %s" % e sys.exit(0) else: print "Connected" if con.auth('secret'): print "connected" else: print "problems with handshake: ", con.lastErr, con.lastErrCode sys.exit(1) con.setMessageHandler(messageCB) while(1): con.process(10) Have fun! dj |