Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Oct 22, 2024

We can still receive the initial value for websocket from the Module object but there is not need to continue to access it via the Module object.

@sbc100 sbc100 force-pushed the websocket_global branch 2 times, most recently from d877393 to dc4486e Compare October 31, 2024 23:01
@sbc100 sbc100 requested review from brendandahl and kripken October 31, 2024 23:01
if (runtimeConfig && null === Module['websocket']['subprotocol']) {
subProtocols = 'null';
opts = undefined;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate change? (I don't seem to see this code moved anywhere else.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I specially handle the === null case above.

We can still receive the initial value for websocket from the Module
object but there is not need to continue to access it via the Module
object.
this._callbacks[event].call(this, param);
}
};
(Module['websocket'] ??= {})['on'] = SOCKFS.on;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need 'emit' as well? Looks like before we had both exported.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think so. The emit for for internal use to send the message. The on is what users would use to register callback.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see that the on property is quoted so that closure won't minify it but the emit helper function is not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (SOCKFS.websocketArgs['subprotocol']) {
subProtocols = SOCKFS.websocketArgs['subprotocol'];
} else if (SOCKFS.websocketArgs['subprotocol'] === null) {
subProtocols = 'null'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
subProtocols = 'null'
subProtocols = 'null';

@sbc100 sbc100 merged commit 29e98f8 into emscripten-core:main Nov 1, 2024
28 checks passed
@sbc100 sbc100 deleted the websocket_global branch November 1, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants