mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-09 11:51:21 +00:00
On Python 3 we need to make sure bytes get written to the websocket.
This commit is contained in:
parent
116c59142d
commit
d99c94753c
@ -5,6 +5,8 @@ from __future__ import (
|
||||
division,
|
||||
)
|
||||
|
||||
from future.builtins import str
|
||||
|
||||
import json
|
||||
|
||||
from autobahn.twisted.resource import WebSocketResource
|
||||
@ -49,7 +51,11 @@ class TokenAuthenticatedWebSocketServerProtocol(WebSocketServerProtocol):
|
||||
"""
|
||||
# probably want a try/except around here? what do we do if
|
||||
# transmission fails or anything else bad happens?
|
||||
self.sendMessage(json.dumps(message))
|
||||
encoded = json.dumps(message)
|
||||
if isinstance(encoded, str):
|
||||
# On Python 3 dumps() returns Unicode...
|
||||
encoded = encoded.encode("utf-8")
|
||||
self.sendMessage(encoded)
|
||||
|
||||
def onOpen(self):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user