Comments (3)
You could do that, but for that you would have to track clients yourself. SocketCluster itself provides socket.id
's but these will change on reconnects. I tested this the changing of the ids via the a client:
const socket = sccClient.create({
hostname: 'localhost',
port: 8000,
autoConnect: false,
});
(async () => {
socket.connect();
for await (const event of socket.listener('connect')) {
console.log('connected', socket.id);
socket.disconnect();
setTimeout(() => {
console.log('reconnecting');
socket.reconnect();
}, 1000);
}
for await (const event of socket.listener('disconnect')) {
console.log('disconnected', socket.id);
}
})()
outputs:
connected ba2gYsb9F-gzcQ-EAAAH
reconnecting
connected aYns1ySMFa41s-MFAAAI
reconnecting
connected EtUcSTujH4pNWZKKAAAJ
What could work is that you set a uuid
on the client, send it to the server and if it disconnects store the payload somewhere and send it again once the same uuid
connects again. Although this probably require some convoluted code to achieve that. I'm unclear if there is something built in to SC @jondubois for this?
from socketcluster.
you are talking about the connection and disconnection update
i am talking about the update that clients missed during their socket disconnection.
e.g the socket is down due to the network and there are some messages for the client during that time how can we send that messages again when the client socket is connected.
from socketcluster.
Let me rephrase, you can't rely on socket.id
. You will have to setup ids of your own on your clients, on connection you will pass them on to the server and then you can track what's their state (connected or disconnected). I don't think this will be easy to implement.
I suggest that you instead store the messages on the server and use .invoke('latest')
on the client and setup a route .procedure('latest')
that provides the latest updates.
Make sense?
from socketcluster.
Related Issues (20)
- Incomplete Protocol Documentation
- Using old ws version HOT 1
- Question about migration from v14 to v16 (listeners cleanup) HOT 1
- Worker is leaving instance repeatedly and reconnects after a while HOT 1
- Is it possible to merge publish messages? HOT 1
- SocketCluster version 16.0.1 SCC problem in minikube k8
- JWT token : invalid signature HOT 1
- `socketcluster create` screws up app name HOT 2
- badSocketAuthToken event not triggering HOT 2
- Unused dependencies HOT 1
- Bump Docker image HOT 1
- Socket connection gets timed out unexpectedly HOT 3
- Potential security issue HOT 5
- We unable received the middleware sending error message from socket client HOT 2
- Has anyone tried to deploy socket cluster on Azure Container apps? HOT 1
- socket.on is not a function HOT 3
- BadConnectionError - socketcluster-client when requesting from server side. It works fine if the request is issued from the browser. HOT 3
- Callbacks scale much more than async/await approach HOT 2
- Namespace in channels HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socketcluster.