From 8afba7de853be4eb3c5cb2467fa17db64cf84abc Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Thu, 22 Jan 2015 16:38:16 +0530 Subject: renamed example for convenience. --- examples/http_over_xmpp.py | 70 ++++++++++++++++++++++++++++++++++++ examples/http_over_xmpp_transport.py | 69 ----------------------------------- 2 files changed, 70 insertions(+), 69 deletions(-) create mode 100644 examples/http_over_xmpp.py delete mode 100644 examples/http_over_xmpp_transport.py (limited to 'examples') diff --git a/examples/http_over_xmpp.py b/examples/http_over_xmpp.py new file mode 100644 index 00000000..5de8713e --- /dev/null +++ b/examples/http_over_xmpp.py @@ -0,0 +1,70 @@ +from sleekxmpp import ClientXMPP +import logging + + +# def tracefunc(frame, event, arg, indent=[0]): +# prefix = "/Users/sangeeth/code/SleekXMPP/sleekxmpp/" +# if not frame.f_code.co_filename.startswith(prefix): +# return tracefunc +# if event == "call": +# indent[0] += 2 +# cn = getattr( +# getattr(frame.f_locals.get("self"), "__class__", None), +# "__name__", None +# ) +# print "{}{} {} {}".format( +# "." * indent[0], frame.f_code.co_filename[len(prefix):], +# cn, frame.f_code.co_name +# ) +# elif event == "return": +# indent[0] -= 2 +# return tracefunc +# +# +# import sys +# sys.settrace(tracefunc) + + +class HTTPOverXMPPClient(ClientXMPP): + def __init__(self, jid, password): + ClientXMPP.__init__(self, jid, password) + + self.register_plugin('xep_0332') # HTTP over XMPP + # self.register_plugin('xep_0030') # Service Discovery + # self.register_plugin('xep_0004') # Data Forms + # self.register_plugin('xep_0060') # PubSub + # self.register_plugin('xep_0199') # XMPP Ping + # + # self.add_event_handler("session_start", self.session_start) + # self.add_event_handler("connected", self.connected) + # + # def session_start(self, event): + # print "Client::session_start()" + # self.send_presence() + # print self.get_roster() + # + # def connected(self, event): + # print "Client::connected()" + + +def get_cred(filename="/tmp/.cred"): + with open(filename, "r") as f: + return f.readline().split() + + +if __name__ == "__main__": + + logging.basicConfig( + level=logging.DEBUG, format='%(levelname)-8s %(message)s' + ) + + jid, password = get_cred() + xmpp = HTTPOverXMPPClient(jid, password) + if xmpp.connect(("talk.l.google.com", 5222)): + print "Connected!" + xmpp.process(block=True) + else: + print "Not connected!" + print "Goodbye...." + + diff --git a/examples/http_over_xmpp_transport.py b/examples/http_over_xmpp_transport.py deleted file mode 100644 index 7a60c6fc..00000000 --- a/examples/http_over_xmpp_transport.py +++ /dev/null @@ -1,69 +0,0 @@ -from sleekxmpp import ClientXMPP -import logging - - -# def tracefunc(frame, event, arg, indent=[0]): -# prefix = "/Users/sangeeth/code/SleekXMPP/sleekxmpp/" -# if not frame.f_code.co_filename.startswith(prefix): -# return tracefunc -# if event == "call": -# indent[0] += 2 -# cn = getattr( -# getattr(frame.f_locals.get("self"), "__class__", None), -# "__name__", None -# ) -# print "{}{} {} {}".format( -# "." * indent[0], frame.f_code.co_filename[len(prefix):], -# cn, frame.f_code.co_name -# ) -# elif event == "return": -# indent[0] -= 2 -# return tracefunc -# -# -# import sys -# sys.settrace(tracefunc) - - -class HTTPOverXMPPClient(ClientXMPP): - def __init__(self, jid, password): - ClientXMPP.__init__(self, jid, password) - - # self.register_plugin('xep_0030') # Service Discovery - # self.register_plugin('xep_0004') # Data Forms - # self.register_plugin('xep_0060') # PubSub - # self.register_plugin('xep_0199') # XMPP Ping - # - # self.add_event_handler("session_start", self.session_start) - # self.add_event_handler("connected", self.connected) - # - # def session_start(self, event): - # print "Client::session_start()" - # self.send_presence() - # print self.get_roster() - # - # def connected(self, event): - # print "Client::connected()" - - -def get_cred(filename="/tmp/.cred"): - with open(filename, "r") as f: - return f.readline().split() - - -if __name__ == "__main__": - - logging.basicConfig( - level=logging.DEBUG, format='%(levelname)-8s %(message)s' - ) - - jid, password = get_cred() - xmpp = HTTPOverXMPPClient(jid, password) - if xmpp.connect(("talk.l.google.com", 5222)): - print "Connected!" - xmpp.process(block=True) - else: - print "Not connected!" - print "Goodbye...." - - -- cgit v1.2.3