-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Fix Socket.io outdated private chat example for Vue #4699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
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
I have implemented the server for private messaging example in react. The frontend of this example is still unimplemented.
Adds improved styling for the forms and the home page
Implements feature to switch between users and also implement the message box
This commit adds a new option, "cleanupEmptyChildNamespaces". With this option enabled (disabled by default), when a socket disconnects from a dynamic namespace and if there are no other sockets connected to it then the namespace will be cleaned up and its adapter will be closed. Note: the namespace can be connected to later (it will be recreated) Related: socketio/socket.io-redis-adapter#480
This commit adds some syntactic sugar around acknowledgements: - `emitWithAck()` ```js try { const responses = await io.timeout(1000).emitWithAck("some-event"); console.log(responses); // one response per client } catch (e) { // some clients did not acknowledge the event in the given delay } io.on("connection", async (socket) => { // without timeout const response = await socket.emitWithAck("hello", "world"); // with a specific timeout try { const response = await socket.timeout(1000).emitWithAck("hello", "world"); } catch (err) { // the client did not acknowledge the event in the given delay } }); ``` - `serverSideEmitWithAck()` ```js try { const responses = await io.timeout(1000).serverSideEmitWithAck("some-event"); console.log(responses); // one response per server (except itself) } catch (e) { // some servers did not acknowledge the event in the given delay } ``` Related: - socketio#4175 - socketio#4577 - socketio#4583
The RemoteSocket interface, which is returned when the client is connected on another Socket.IO server of the cluster, was lacking the `timeout()` method. Syntax: ```js const sockets = await io.fetchSockets(); for (const socket of sockets) { if (someCondition) { socket.timeout(1000).emit("some-event", (err) => { if (err) { // the client did not acknowledge the event in the given delay } }); } } ``` Related: socketio#4595
So that the client knows whether the connection state recovery feature is enabled. See also: socketio@54d5ee0
This reverts commit 4e64123. Using the id of the socket is not possible, since it is lost upon reconnection (unless connection recovery is successful), so we revert the previous change.
…bled This is a follow-up commit of [1]. Without it, adapter.persistSession() would be called even if the connection state recovery feature was disabled. [1]: socketio@54d5ee0
The import added in [1] was invalid, because it used an non-exported class. Related: socketio#4621 [1]: socketio@d4a9b2c
Namespaces that match the regex of a parent namespace will now be added as a child of this namespace: ```js const parentNamespace = io.of(/^\/dynamic-\d+$/); const childNamespace = io.of("/dynamic-101"); ``` Related: - socketio#4615 - socketio#4164 - socketio#4015 - socketio#3960
@haneenmahd it seems there is a problem with the PR, there are a lot of unrelated changes. Did you rebase against the main branch? |
Sorry, It is rebased from the main branch. I will fix that and open a new PR. |
Superseded by cbf0362. Thanks 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The kind of change this PR does introduce
Current behavior
The current private chat example for vue does have two problems, it's outdated and uses legacy ssl provider. This means it can't run on Node version above 16. Other issues are with installing dependencies and people getting confused of why a redis connection error has occured.
New behavior
I have fixed the issue by adding
NODE_OPTIONS=--openssl-legacy-provider
while serving the website and also adding documentation that improves the understanding of getting started with the example.Other information (e.g. related issues)
#4681