[Feature discussion] Socket.io extension #2346
Replies: 12 comments
-
My opinion- Also, eagerly waiting for your Firebase extension PR to get approved and thanks for the peerjs extension. |
Beta Was this translation helpful? Give feedback.
-
Since gecko and socket.io are so similar, why not provide both at once? The difference is basically TCP vs UDP, and both always had had their defaults. UDP may be faster but it is less reliable and more vulnerable (more vulnerable as it is easier to spoof the IP the packet came from). I think I could easily put in the connect to server action a toggle to choose which one to use. Socket.io also has been throughly tested, is trusted by big enterprises, and isn't dependent on newer technologies as it has fallbacks for older browsers, so trashing it away because another library claims to have a little bit less latency might be a bit of an excessive reaction ;) Thanks you very much for your suggestion of using gecko tho as it might indeed be interresting as an alternative backend for providing UDP. |
Beta Was this translation helpful? Give feedback.
-
Thanks both! These discussions are very interesting.
Remember that while giving the "choice" seems naively better, it's also more things to maintain, the double of stuff to test, more confusion for the users... in some cases, "less is more" as we say :) Network is notoriously something complicated - very few, if any, game engine managed to make it simple. That's a huge challenge for GDevelop, so we need to document ourselves a lot and understand what are the main challenges before! :) |
Beta Was this translation helpful? Give feedback.
-
So may be we should wait for some time(ideally, a month) to see how well the peerjs extension ( as mentioned above by @arthuro555 ) works and problems(if any) . |
Beta Was this translation helpful? Give feedback.
-
Geckos io made a handy little table comparing meet js, socket io and geckos io: For now, I would therefore stick to socket.io due to it's wider application range. If we get a high demand for UDP/faster real time networking we can always look back into gecko. |
Beta Was this translation helpful? Give feedback.
-
It provides a way of sending reliable messages which can be used for turn-based multiplayer whereas the default non-reliable mode can be used for realtime multiplayer.
It does not require external signaling servers,that's built-in. The README mentions about external ICE servers which defaults to google-provided public ICE servers, thats also the case for peerjs . Also, after reading your comment and searching on npm, I came across this ICE server for node. (I haven't tested this server with geckos.io.)
There is an open issue regarding the table. |
Beta Was this translation helpful? Give feedback.
-
Capable of something != Good at that thing. Gecko explicitly says that it shouldn't be used with the reliable option as a default and should only be used as a last resort.
The question is not about what p2p does but what library we want to use for socket networking ;) In general I personally prefer to rely on proven technology. Gecko is not very used (in comparison to socket.io) and is therefore more prone to bugs/issues, and those could make GDevelop look unprofessional. Socket.io is definitely good enough for anything any GDevelop user would want to make, and is a safer bet. Don't get me wrong gecko is not bad or anything, it is just that a choice has to be made, and sockets.io is just more reliable, more likely to stay maintained, and reliable connections are easier to understand than unreliable ones. Imagine how many users would be confused as to why some of the events they send never arrive! If someone makes a game big enough and know what they are doing and are trying to optimize to the maximum, and switching to UDP would become worth it, they probably would have the resources to implement it themselves. |
Beta Was this translation helpful? Give feedback.
-
Does this mean though that with socket.io, we close the door to "fast action paced" games, only officially supporting turn by turn or games with no issue of latency? |
Beta Was this translation helpful? Give feedback.
-
This is just people being ignorant to actually look into things and following the AAA crowd that always says tcp is slow @4ian many fast paced games use TCP(Websockets) Krunker |
Beta Was this translation helpful? Give feedback.
-
At the beginning,I would like to state that I haven't made any game using either socket.io/geckos.io, so I do not have any first-hand experience. I was leaning towards webrtc because I came across some articles -one of the published by chrome team which state that current websocket API isn't suitable for very fast realtime updates. Also, construct 3 (most probably construct 2 also) uses webrtc for multiplayer and webrtc has pretty good browser support However,majority(in this thread) seems to be on socket.io side, so let it be socket.io . If required, I will make a geckos.io extension later on. |
Beta Was this translation helpful? Give feedback.
-
Yes I know that geckos is potentially faster for games with many updates, but reliability is probably more important for most users. To sum it up, my main argument in favor of socket.io is that we want an easy solution for users. Reliability is something they expect. My second argument is that socket.io is a big library heavily used by big tech companies (Trello for example), so even if it would stop being maintained one of those companies would fork it for sure and continue maintaining it. It has also been around longer and has therefore more stability. Finally my last argument is that really fast games with many event calls might not work well at all due to the GDevelop event loop. If we use the same system as for p2p, there will always be a limit of 1 event that can be processed every frame. To really optimize at the maximum you would need to handle events with asynchronous JavaScript anyways, so it wouldn't be that difficult to also add gecko as include through the DOM or by just pasting the JavaScript file into a JavaScript event.and use it. |
Beta Was this translation helpful? Give feedback.
-
This is something that is more complex I think. Synchronization loss will happen, whatever your solution is. It's not a "if" question, it's a "when" question :) Seems like some games, like in Valve Source engine, are having an authoritative server sending very frequently the state of the world (i.e: position of objects basically, like the players). See "lag compensation" and "input prediction" on this article: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking Another article: https://medium.com/@qingweilim/how-do-multiplayer-games-sync-their-state-part-1-ab72d6a54043
We should not consider the events sheet as a bottleneck. There are many way of handling more than one event, with a custom event type that would repeat for each received event, with something like a condition that "unstack" the received event each time a condition is called, etc.. in another words something to make a loop allowing to treat more than one event. Note that what I wrote here is not telling if we should go for one library or the other. Just, that it's more complicated than just "choosing a fast library or a reliable one" (all of this is if we want an extension that is higher level than the current "peer to peer" extension and that allows to build multiplayer games easily. If we just want to "expose" the API of socket.io/gecko, it's easy but will certainly not be helpful to users that will be frustrated by the fact that it's too low level and they can't do their dream multiplayer games). |
Beta Was this translation helpful? Give feedback.
-
Description
The p2p extension is cool but it has some limitations and is not the fastest. Some limitations are that if you want a server architecture, people can potentially steal your connection UID and take control of the server, plus you need to basically run the server in a headless browser (not the best in resources management). It also has the annoying 250 simultaneous connection limit.
Solution suggested
We could adapt the asynchronous to synchronous queueing system of the peer to peer extension for socket.io and socket.io-server, to let users write their own servers (only catch is servers would only work in a node environment) and clients. This would allow making real lan games, reliable server client architectures, an architecture like Minecraft (if you multiplayer host a server) etc.
Alternatives considered
We could also use websockets but socket io has fallbacks in case they are not supported and adds auto reconnect on unreliable connections.
Prerequisites
We need two things to be done before implementing this issue:
Beta Was this translation helpful? Give feedback.
All reactions