Closed Lazhor closed 1 year ago
I answered your - now deleted - question... Basically saying that for the web you could use JavaScriptBridge
and otherwise I didn't know what, because Socket.IO didn't offer any other clients.
Since that, it has come to my attention that there is third party client for .NET, thus it might be possible to use it from C# in Godot. It might also be a good starting point for a Godot implementation.
I don't expect this to be added to Godot core regardless.
Without this enhancement, those who use Socket.IO in their servers are limited in their usage of Godot, as it is not possible to use GDScript directly to get around this.
It should be possible to implement a socket.io client using the WebSocketClient class. To my knowledge, this is the only backend socket.io can run on (since browsers can't send raw TCP/UDP packets, and I don't think socket.io can use WebRTC due to the complexity).
@theraot First, it wasn't me you were replying to. Second, in the first paragraph, you're not making any coherent points. Third, I came to Godot to use GDScript; otherwise, I would have stayed with Unity (C#). And finally, I'm surprised by your comment in the third paragraph, saying that you don't expect this to be added to the core of Godot. It's a foolish comment. Instead of wanting Godot to grow and provide more and more tools, that's what you have to say. Unfortunately, I've come across many people in the Godot community with this kind of thinking. You should come together instead of having this kind of behavior.
Since that wasn't you and I was mistaken, I'll explain in more detail what I mean about JavaScriptBridge
:
If your game is for the web (which I don't know if it is), then you can modify the HTML of the page Godot generates (Custom HTML page for Web export) to include the official Socket.IO library, and then you can interface with it from the game using the JavaScriptBridge
class.
About C#, it is the only way I've found you'd had a chance to include Socket.IO in a desktop Godot game, if you need a solution right now. If you are on a tight schedule (which I don't know if you are), it might be worth looking into.
And finally, no, I don't expect this to be in Godot core. I'd expect this be made as addon by the community that you claim does not come together, instead of burden on the core developers.
@Calinou First Thank you! I've also tried using the WebSocketClient Class in hopes of trying to connect to the Socket.IO server, but it's not available, see the print below:
@theraot Thank you for your suggestion! You Didn't read it properly! I didn't say the entire community; I said I've encountered MANY PEOPLE WITH THIS KIND OF THINKING... who even made fun of it. If I knew how to create an addon myself, I would have done it and made it available to the whole community because when I started developing in Godot, I realized it's an amazing tool, and unfortunately, it has little visibility. Personally, I find it more practical than Unity, especially considering that GDScript is much easier than C#, and the way Godot works is very intuitive and efficient.
I think it should be fairly straightforward to create a Socket.IO implementation in GDScript as a plugin. It would require some research and a bit of work, but certainly possible.
I think you'd need to use the HTTPClient
class to do the initial connection, then upgrade to WebSocketPeer
. You would then need to implement the protocol itself. There is documentation here:
https://socket.io/docs/v4/engine-io-protocol/ https://socket.io/docs/v4/socket-io-protocol/
@nisovin Possible certainty is, after all, in several languages many create their own solutions! But since you suggested it, great, then create a repository on GitHub, and let's add the gelera that wants and understands enough to implement your suggestion, after all, as you think it's quite simple, you should be ahead of it, and you can put me, that in what I can help, I'm at your disposal!
Finally Solved! Thank you all.
If you said you solved it, please share the solution
I've created a basic and incomplete implementation here:
https://github.com/nisovin/godot-socketio
It's lacking a lot, so it's more of a proof-of-concept. But it's there if anyone wants to take a look, and should serve as a good starting point.
Describe the project you are working on
We have a multiplayer server for games, but we use Socket.IO for that, and while we were migrating a multiplayer 2D game from Unreal to Godot, we realized that it would not be possible to continue due to this.
Describe the problem or limitation you are having in your project
The only limitation we noticed in Godot is the lack of a Socket.IO client for those who have servers that use Socket.IO.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
I was recently migrating my game from Unreal to Godot, we were interested in using Godot for 2D games (Mobile) and leaving only 3D in Unreal, Godot is super simple and easy to use and everything is very quick to implement, however, we realized that it does not have a Socket.IO Client so that we can connect to our Multiplayer server, and WebSocketPeer or other solutions that we look for in the documentation, are not useful for those who have a Socket.IO server, for that it is necessary a Specific Client for it . If possible, it would be great for the whole community to implement an Addon/Library for the Socket.IO Client at Godot. (Actually, we were even surprised that Godot didn't have it, since all engines have it, even if it's not official). Thank you very much in advance!
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
We believe that the most appropriate approach would be to create a class for Socket.IO, similar to the WebSocketPeer/TCP/UDP classes in Godot. Pseudo-code Example:
If this enhancement will not be used often, can it be worked around with a few lines of script?
Without this enhancement, those who use Socket.IO in their servers are limited in their usage of Godot, as it is not possible to use GDScript directly to get around this.
Is there a reason why this should be core and not an add-on in the asset library?
Many developers use Socket.IO, and I have seen some inquiries in the Discord Community, so I believe it would be interesting for Godot to implement this enhancement and promote it, as surely many have encountered this limitation.