You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Buffer is a Node module, but this library is supposed to mock the client web socket and is not supposed to create a copy of the Node WebSocket implementation (Anyway the server can be written in any language).
The normalizeSendData function is called both on the client and server, but the only thing it should do right is to mimic the client's behavior. So if you want to pass the data to the WebSocket client in the test I think you can just pass the string or blob/arraybuffer data as the client expects (not the Buffer instance), as you test the client, not the server.
@bytemain Can you share an example of the issue?
According to the spec the client WebSocket can accept/send only these types: string, blob and ArrayBuffer, (see https://websockets.spec.whatwg.org/#feedback-from-the-protocol p3 and p4). All these types should be handled properly in the mock-socket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
From what I experienced with web sockets, Buffer messages are transmitted as ArrayBuffer in the message event.
This modification may break some people implementations but should be closer to real behaviour.
Happy to have your feedback.