Comments (3)
def initialize(channel, controller = 0)
so when i init the client, i specify controller=1 , how do i think store that clients "ID" that I can parse when each client closes?
from iodine.
@rschwass , thank you for opening this issue and for your interest in iodine.
Since the HTTP request's env
Hash object is accessible through client.env
, it should be quite easy to produce a UUID and assign it to the connection. It should be quite easy to store this connection's UUID as well as the originating processes' ID in a database of some sorts...
However, for most use cases, this approach would create scalability issues.
For example, assuming you want to create an "online" indicator for a user: How do the connection indicators link to a specific user? What would happen if a user comes online on two different browsers, or on a browser + app? Does each connection get a different uuid? What if two different machines handle these connections? What if a server crashes or goes offline before calling the connection's on_closed
callback?
Much better to handle this as a user related event, using the user's ID rather than the connection ID, separating the online/offline
responsibility from the connection object.
i.e., publish an {event: "connected", user: "[email protected]", at: Time.now}
or an event {event: "disconnected", user: "[email protected]", at: Time.now}
. Let the event handler (which might be a different micro-service) increase or decrease a user associated online
counter. Perhaps add a last-seen
indicator, or a timer, or listen to some user produced events (such as ack
events), so the online count is reset if a client doesn't answer a ping
or appears inactive for too long (having a browser open doesn't mean the person is still there)...
Suddenly, instead of handling connections, you focus on the user itself - a much more relevant entity.
I hope this helps. I wish you the best of luck.
from iodine.
Thank you. My clients are not users but machines. I ended up going with the client.env method.
from iodine.
Related Issues (20)
- Question about crashes HOT 2
- Assertion failure HOT 9
- Iodine failing to compile with Ruby 3.2.0preview_2 HOT 5
- The future of iodine (vs. plezi)...? HOT 9
- [Rack 3] Response headers with Array value should produce multiple header fields HOT 3
- CPU usage when idle HOT 3
- Iodine.unsubscribe crashes when called with symbol. HOT 4
- Subscribing from the enter_master block subscribes even the children. HOT 3
- unix socket not writeable due umask HOT 8
- Writes to STDOUT even when Iodine.verbosity = 0 HOT 1
- Does not honor HUP signal. HOT 1
- Iodine stops on TERM signal with error when it run with -pid key and more than one worker HOT 1
- The Fixnum is gone as of Ruby-2.4 HOT 3
- response code 418 results in 500 Internal Server Error HOT 1
- [FEAT] return reason for closed connection/client HOT 7
- Static file serving: allow mounting of multiple local dirs HOT 14
- binary C extension not built? HOT 26
- ondisconnect example HOT 1
- rage-rb HOT 1
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 iodine.