Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions rosbridge_library/src/rosbridge_library/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@ def incoming(self, message_string=""):
message_string -- the wire-level message sent by the client

"""
if len(self.buffer) > 0:
self.buffer = self.buffer + message_string
else:
self.buffer = message_string
self.buffer = self.old_buffer + message_string
if self.buffer == self.old_buffer:
return
msg = None

# take care of having multiple JSON-objects in receiving buffer
Expand Down Expand Up @@ -217,13 +216,13 @@ def incoming(self, message_string=""):
except Exception as exc:
self.log("error", f"{op}: {str(exc)}", mid)

# if anything left in buffer .. re-call self.incoming
# TODO: check what happens if we have "garbage" on tcp-stack --> infinite loop might be triggered! .. might get out of it when next valid JSON arrives since only data after last 'valid' closing bracket is kept
if len(self.buffer) > 0:
# try to avoid infinite loop..
if self.old_buffer != self.buffer:
try:
if len(self.buffer) > 0:
self.old_buffer = self.buffer
self.buffer = ""
self.incoming()
except Exception as exc:
self.log("error", f"{self.client_id}: {str(exc)}")

def outgoing(self, message, compression="none"):
"""Pass an outgoing message to the client. This method should be
Expand Down