I’ve made a simple multiplayer game using socket.io, and took a lot of help from youtube and internet on how to do it. but all of the tutorials only talk about how to run the server locally, and none of the ones that i followed ever talked about running the server online (and i looked a lot!).
So is there any tutorials on this? or can anyone help me? I’m not really familiar with javascript and node.js, but for my current situation, copy pasting is good enough. thanks.
Firstly, and take this advice with a pinch of salt because I’m a bit of a veteran: multiplayer is complicated. Very complicated. You are going to eventually need to do a hell of a lot more than copy and paste because with everything that is involved, that won’t be “good enough”.
To put you on the right track though, your “local” environment will be set up so that your connection to the socket is done over a local address. Such as “localhost” or your local ip address “127.0.0.1”. So, getting things set up so that you are connecting to a remote socket, you would merely set things up so that the socket is on a remote server, and then connect to the ip address of the remote server. There’s a little more to it than that, but that should be enough to get you started.
Good luck!
thank you for the reply. now that i have finally found a veteran, let me go full in, and explain my situation and what i need.
been 3 days that i’ve started a job as a unity game dev, and i wasn’t bad at programming gameplay, ui, etc. but never touched networking, and now i’ve took on an incomplete game, which is in this state:
the guy before me has almost completely finished the job. the server side script is done, has been copied to the server (which is hosted by us) and runs fine. and the client side codes - except a little of the gameplay - had been done too, and the game could communicate with the server with no problem. the problem now is that the guy who wrote these stuff had a falling out with the ceo, and has deleted the client side source codes. all we have now is an old backup, to when he was testing in local environment.
so after researching and asking around a lot, i finally figured out how to run the server, and now my question is this: what should i put inside the Uri property, in the “SocketIOComponent” script in the inspector? (im asking for the logic behind it, not the exact line!)
I can’t help but have some sympathy for your situation, there’s nothing worse than having to fix other people’s mess. Hats off to you though for actually taking on that challenge. I wouldn’t go near a mess like that no matter what they were paying me!
To answer your question though. What kind of socket is it? Udp, tcp, websocket etc? If you know the ip address of the server you are running your server-side on, it should be case of something like: udp://123.456.789:1234.
- replace “udp” with tcp for a raw tcp socket. Or “ws” for non-secure websocket and “wss” for a secure websocket
- “123.456.789” replace with the server ip
- “1234” replace with the port number that the socket is listening to on the server-side
Good luck man, you’re going to need it!
1 Like
thanks for the sympathy, it helps feeling less enraged! and thank you so much for the tip too. it worked like a charm. I’ve made all that i learned these two days about running a multiplayer game in online (not local), made with Socket.io, into an image for my future reference, for those also stuck in my situation, and also as a final step of most of the tutorials out there:
anybody depending on their situation may run into some additional problems, but i hope this helps smooth the path a little.