fix: support fragmented websocket frames, resolves #77 #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses the issue #77, where
atomic-chrome-on-messagefunction failed to handle incomplete frames, leading to JSON parsing errors for concatenated frames. The problem was initially outlined by @ahyatt while investigating a related issue in theemacs-websocketrepository.To resolve this, the following changes have been made in
atomic-chrome.el:Introduction of a hash table,
atomic-chrome-frame-socket-incomplete-buffers-hash, to keep track of incomplete frame payloads associated with a specific websocket connection. This enhancement ensures that payloads from incomplete frames are accumulated efficiently until the final fragment is received.Modification of the
atomic-chrome-on-messagefunction to support the handling of incomplete frames. The function now checks if a given frame is complete and, if not, appends its payload to a buffer designated for that socket's incomplete messages. Upon receiving the final fragment, it reconstructs the full payload, decodes it, and processes it as a JSON object. This process allows for the creation or update of Emacs buffers associated with the editing session.Cleanup logic in the
atomic-chrome-on-closefunction to remove any stored incomplete frame payloads once a websocket connection is closed.Looking forward to your feedback and hoping for a merge into the main repository.