summaryrefslogtreecommitdiff
path: root/examples/ibb_transfer
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ibb_transfer')
-rwxr-xr-xexamples/ibb_transfer/ibb_receiver.py14
-rwxr-xr-xexamples/ibb_transfer/ibb_sender.py4
2 files changed, 8 insertions, 10 deletions
diff --git a/examples/ibb_transfer/ibb_receiver.py b/examples/ibb_transfer/ibb_receiver.py
index b11acabf..6aba98e3 100755
--- a/examples/ibb_transfer/ibb_receiver.py
+++ b/examples/ibb_transfer/ibb_receiver.py
@@ -21,8 +21,8 @@ import sleekxmpp
# throughout SleekXMPP, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
- reload(sys)
- sys.setdefaultencoding('utf8')
+ from sleekxmpp.util.misc_ops import setdefaultencoding
+ setdefaultencoding('utf8')
else:
raw_input = input
@@ -38,7 +38,7 @@ class IBBReceiver(sleekxmpp.ClientXMPP):
self.register_plugin('xep_0030') # Service Discovery
self.register_plugin('xep_0047', {
- 'accept_stream': self.accept_stream
+ 'auto_accept': True
}) # In-band Bytestreams
# The session_start event will be triggered when
@@ -48,7 +48,7 @@ class IBBReceiver(sleekxmpp.ClientXMPP):
# our roster.
self.add_event_handler("session_start", self.start)
- self.add_event_handler("ibb_stream_start", self.stream_opened)
+ self.add_event_handler("ibb_stream_start", self.stream_opened, threaded=True)
self.add_event_handler("ibb_stream_data", self.stream_data)
def start(self, event):
@@ -69,7 +69,7 @@ class IBBReceiver(sleekxmpp.ClientXMPP):
def accept_stream(self, iq):
"""
- Check that it is ok to accept a stream request.
+ Check that it is ok to accept a stream request.
Controlling stream acceptance can be done via either:
- setting 'auto_accept' to False in the plugin
@@ -83,9 +83,7 @@ class IBBReceiver(sleekxmpp.ClientXMPP):
return True
def stream_opened(self, stream):
- # NOTE: IBB streams are bi-directional, so the original sender is
- # now the opened stream's receiver.
- print('Stream opened: %s from ' % (stream.sid, stream.receiver))
+ print('Stream opened: %s from %s' % (stream.sid, stream.peer_jid))
# You could run a loop reading from the stream using stream.recv(),
# or use the ibb_stream_data event.
diff --git a/examples/ibb_transfer/ibb_sender.py b/examples/ibb_transfer/ibb_sender.py
index cd856378..7c380b68 100755
--- a/examples/ibb_transfer/ibb_sender.py
+++ b/examples/ibb_transfer/ibb_sender.py
@@ -21,8 +21,8 @@ import sleekxmpp
# throughout SleekXMPP, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
- reload(sys)
- sys.setdefaultencoding('utf8')
+ from sleekxmpp.util.misc_ops import setdefaultencoding
+ setdefaultencoding('utf8')
else:
raw_input = input