Test README commands
This commit is contained in:
parent
0d1a2b9ca2
commit
444386f271
5 changed files with 27 additions and 11 deletions
|
|
@ -42,6 +42,7 @@ Launch your socket.io server. ::
|
|||
For debugging information, run these commands first. ::
|
||||
|
||||
import logging
|
||||
logging.getLogger('requests').setLevel(logging.WARNING)
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
Emit. ::
|
||||
|
|
@ -144,7 +145,7 @@ Wait forever. ::
|
|||
|
||||
from socketIO_client import SocketIO
|
||||
|
||||
socketIO = SocketIO('localhost')
|
||||
socketIO = SocketIO('localhost', 8000)
|
||||
socketIO.wait()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
Release 0.6.1 #41 #52
|
||||
Run README commands
|
||||
Fix for Python 3
|
||||
Merge sarietta's pull request
|
||||
Add Websocket transport
|
||||
Update proxy to include websocket depending on argument
|
||||
Use prepared request to get headers from http_session
|
||||
Include https://github.com/invisibleroads/socketIO-client/issues/68
|
||||
Consider logging packets sent and received
|
||||
Implement rooms #65
|
||||
Implement binary event
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class EngineIO(LoggingMixin):
|
|||
self._opened = False
|
||||
if Namespace:
|
||||
self.define(Namespace)
|
||||
self._transport
|
||||
|
||||
# Connect
|
||||
|
||||
|
|
@ -149,6 +150,7 @@ class EngineIO(LoggingMixin):
|
|||
|
||||
def _close(self):
|
||||
self._wants_to_close = True
|
||||
self._heartbeat_thread.stop()
|
||||
if not self._opened:
|
||||
return
|
||||
engineIO_packet_type = 1
|
||||
|
|
@ -169,6 +171,7 @@ class EngineIO(LoggingMixin):
|
|||
def _message(self, engineIO_packet_data):
|
||||
engineIO_packet_type = 4
|
||||
self._transport.send_packet(engineIO_packet_type, engineIO_packet_data)
|
||||
self._debug('[socket.io packet sent] %s', engineIO_packet_data)
|
||||
|
||||
@retry
|
||||
def _upgrade(self):
|
||||
|
|
@ -292,6 +295,10 @@ class SocketIO(EngineIO):
|
|||
|
||||
# Connect
|
||||
|
||||
@property
|
||||
def connected(self):
|
||||
return self._opened
|
||||
|
||||
def _connect_namespaces(self):
|
||||
for path, namespace in self._namespace_by_path.items():
|
||||
namespace._transport = self._transport_instance
|
||||
|
|
@ -387,6 +394,7 @@ class SocketIO(EngineIO):
|
|||
engineIO_packet_data = super(SocketIO, self)._process_packet(packet)
|
||||
if engineIO_packet_data is None:
|
||||
return
|
||||
self._debug('[socket.io packet received] %s', engineIO_packet_data)
|
||||
socketIO_packet_type = int(get_character(engineIO_packet_data, 0))
|
||||
socketIO_packet_data = engineIO_packet_data[1:]
|
||||
# Launch callbacks
|
||||
|
|
|
|||
|
|
@ -149,15 +149,15 @@ class LoggingEngineIONamespace(EngineIONamespace):
|
|||
super(LoggingEngineIONamespace, self).on_close()
|
||||
|
||||
def on_ping(self, data):
|
||||
self._debug('[ping] %s' % data)
|
||||
self._debug('[ping] %s', data)
|
||||
super(LoggingEngineIONamespace, self).on_ping(data)
|
||||
|
||||
def on_pong(self, data):
|
||||
self._debug('[pong] %s' % data)
|
||||
self._debug('[pong] %s', data)
|
||||
super(LoggingEngineIONamespace, self).on_pong(data)
|
||||
|
||||
def on_message(self, data):
|
||||
self._debug('[message] %s' % data)
|
||||
self._debug('[message] %s', data)
|
||||
super(LoggingEngineIONamespace, self).on_message(data)
|
||||
|
||||
def on_upgrade(self):
|
||||
|
|
@ -180,15 +180,15 @@ class LoggingEngineIONamespace(EngineIONamespace):
|
|||
class LoggingSocketIONamespace(SocketIONamespace):
|
||||
|
||||
def on_connect(self):
|
||||
self._debug('%s [connect]' % self.path)
|
||||
self._debug('%s[connect]', _make_logging_header(self.path))
|
||||
super(LoggingSocketIONamespace, self).on_connect()
|
||||
|
||||
def on_reconnect(self):
|
||||
self._debug('%s [reconnect]' % self.path)
|
||||
self._debug('%s[reconnect]', _make_logging_header(self.path))
|
||||
super(LoggingSocketIONamespace, self).on_reconnect()
|
||||
|
||||
def on_disconnect(self):
|
||||
self._debug('%s [disconnect]' % self.path)
|
||||
self._debug('%s[disconnect]', _make_logging_header(self.path))
|
||||
super(LoggingSocketIONamespace, self).on_disconnect()
|
||||
|
||||
def on_event(self, event, *args):
|
||||
|
|
@ -196,11 +196,13 @@ class LoggingSocketIONamespace(SocketIONamespace):
|
|||
arguments = [repr(_) for _ in args]
|
||||
if callback:
|
||||
arguments.append('callback(*args)')
|
||||
self._info('%s [event] %s(%s)', self.path, event, ', '.join(arguments))
|
||||
self._info(
|
||||
'%s[event] %s(%s)', _make_logging_header(self.path), event,
|
||||
', '.join(arguments))
|
||||
super(LoggingSocketIONamespace, self).on_event(event, *args)
|
||||
|
||||
def on_error(self, data):
|
||||
self._debug('%s [error] %s' % (self.path, data))
|
||||
self._debug('%s[error] %s', _make_logging_header(self.path), data)
|
||||
super(LoggingSocketIONamespace, self).on_error()
|
||||
|
||||
|
||||
|
|
@ -212,3 +214,7 @@ def find_callback(args, kw=None):
|
|||
return kw['callback'], args
|
||||
except (KeyError, TypeError):
|
||||
return None, args
|
||||
|
||||
|
||||
def _make_logging_header(path):
|
||||
return path + ' ' if path else ''
|
||||
|
|
|
|||
|
|
@ -24,14 +24,12 @@ class BaseMixin(object):
|
|||
|
||||
def test_disconnect(self):
|
||||
'Disconnect'
|
||||
self.socketIO.emit('whee')
|
||||
self.assertTrue(self.socketIO.connected)
|
||||
self.socketIO.disconnect()
|
||||
self.assertFalse(self.socketIO.connected)
|
||||
# Use context manager
|
||||
with SocketIO(HOST, PORT, Namespace) as self.socketIO:
|
||||
namespace = self.socketIO.get_namespace()
|
||||
namespace.emit('whee')
|
||||
self.assertFalse(namespace.called_on_disconnect)
|
||||
self.assertTrue(self.socketIO.connected)
|
||||
self.assertTrue(namespace.called_on_disconnect)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue