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
What's the difference between io.Manager and io.Socket? #1214
Comments
+1 |
1 similar comment
+1 |
Yeah it seems like the documentation tells us how to create these, but doesn't tell us what makes them unique and when to use one or the other. |
as I try so far, most of manager property could be directly applied in io piece
And that is what I want perfectly. |
#metoo I'd love to know the difference, if there's one, between:
And what's the pourpose of:
I can't seem to find anything usable in the documentation apart a very detailed but cold description of the parameters. Also, if I can use in my browser's client html page either socket.io or socket.io-client Thank you and sorry, I see lots of work has been put on this library but it's very confusing to get an hang of it. |
I completely agree. I can't find any difference between the manager and socket instances. |
+1, |
+1 |
Menh!! so no response on this yet??? like wth!! |
Hi! I've added more details about the Manager and the Socket classes here and here.
Basically, the manager instance is implicitly created when running const socket = io();
const socket2 = io("/test2");
// socket.io === socket2.io
const socket3 = io("/test3", { forceNew: true }); // new manager
// socket.io !== socket3.io Regarding the events, the following events are related to the state of the connection and will be emitted by both the Manager and its associated Sockets:
The Socket will emit these additional events, which are related to the Namespace:
Please tell me if that's clear enough. And sorry for the delay! |
@darrachequesne Thank you for your explanation, aslo can you explan a little bit the differece between
|
I think both // https://github.com/socketio/socket.io-client/blob/2.3.0/lib/index.js#L15
module.exports = exports = lookup;
// https://github.com/socketio/socket.io-client/blob/2.3.0/lib/index.js#L85
exports.connect = lookup; Now, why are there two different ways of doing the same thing, that's a good question... 😄 . It seems to be like that since 2012: d5652fe. I'll check if there are specific reasons for that, but else the Regarding the manager constructor, maybe it should be removed from the public API. Basically: const socket = io("ws://example.com/my-namespace", {
reconnectionDelayMax: 10000,
query: {
auth: "123"
}
});
// is the same as
const manager = new Manager("ws://example.com", {
reconnectionDelayMax: 10000
});
const socket = manager.socket("/my-namespace", {
query: {
auth: "123"
}
}); |
I've updated the documentation: socketio/socket.io-website@e779468 Hope that's clearer now! |
Having access to the manager makes a lot of sense, so this way you can have full control of the socket instances instead of using the global default manager that the package holds underneath which could also be shared by another package f.e.. |
I am kind of new to the socket.io-client. After reading the doc for several times, I still don't understand what the differences between io.Manager and io.Socket. Basically I can generate a new socket from io(). but how can I generate a manager instance? Meanwhile, what's the differences between Manager's event and Socket's event.
thank you.
The text was updated successfully, but these errors were encountered: