Skip to content

Commit

Permalink
Fix Autobahn WebSocket vs. Python 3 (#451)
Browse files Browse the repository at this point in the history
Fixes #448
  • Loading branch information
mvollrath authored and jihoonl committed Jan 6, 2020
1 parent 4fe386b commit 856987e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions rosbridge_server/src/rosbridge_server/autobahn_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def onOpen(self):

def onMessage(self, message, binary):
cls = self.__class__
if not binary:
message = message.decode('utf-8')
# check if we need to authenticate
if cls.authenticate and not self.authenticated:
try:
Expand Down Expand Up @@ -188,6 +190,7 @@ def outgoing(self, message):
message = bytes(message)
else:
binary = False
message = message.encode('utf-8')

self.sendMessage(message, binary)

Expand Down
2 changes: 1 addition & 1 deletion rosbridge_server/test/websocket/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def onOpen(self):
}, NUM_MSGS)

def _sendDict(self, msg_dict, times=1):
msg = json.dumps(msg_dict)
msg = json.dumps(msg_dict).encode('utf-8')
for _ in range(times):
self.sendMessage(msg)

Expand Down

0 comments on commit 856987e

Please sign in to comment.