Fixed int and float compression errors

This commit is contained in:
Philip Trauner 2016-10-03 20:50:00 +02:00
parent 07031d719c
commit 1105b0fc8c

View file

@ -50,6 +50,7 @@ class Meta:
def run(self, data, handler):
if type(data) is dict:
handler.peer_exchange_routes = data
if handler.debug:
Logging.success("Received peer exchange routes: %s" % str(data))
handler.peer_reverse_exchange_routes = reverse_dict(handler.peer_exchange_routes)
if issubclass(handler.__class__, Client):
@ -57,11 +58,12 @@ class Meta:
try:
handler.ready()
except AttributeError:
Logging.warning("Consider to add a ready method to your handler. "
"Without one, it's pretty much useless.")
pass
if handler.debug:
Logging.info("Launching routes.")
Routing.launch_routes(handler.routes, handler)
if handler.debug:
Logging.info("Routes launched.")
if type(data) is int:
if data == 1:
Logging.error("Last route was invalid.")
@ -87,6 +89,8 @@ def prepare_data(data):
data_type = DATA_TYPES[bytes]
if original_data_type is str:
data = data.encode()
elif original_data_type in (int, float):
data = str(data).encode()
elif original_data_type is dict or original_data_type is list:
data = json.dumps(data, separators=(',',':')).encode()
elif original_data_type is NoneType: