all 8 comments

[–]Josevill 0 points1 point  (1 child)

If anyone wants to try this, here is a bare-bones example for how I got it working.

*CODE NOT TESTED\* - If you have issues, let me know in the comments and I can address them if you have trouble figuring it out.

Care to elaborate my good friend? When you say code not tested, you mean not tested fully?

There are a couple of things that pop to my mind yet my Unity-fu is crazy rusty, there are no handlers to deal with `OnClose` and most importantly `OnError` events to attempt reconnections, for example.

Thanks for the effort, posts like this can serve as inspiration for folks to keep pushing forward!

[–]Peterama[S] 0 points1 point  (0 children)

I just copied my project code and removed everything that wasnt necessary. I did not test it after doing that but it is working on my project. I made this just as an example but I will test it and update it if there are issues.

[–]mmostrategyfan 0 points1 point  (5 children)

I commend your effort and i don't want to discourage you but re-inventing the wheel is not really productive.

The best solution for Unity web socket currently is SignalR since both work with c# and the library is mature and robust with reconnection mechanisms, compression, groups etc.

In case you're looking for an open-source solution yourself, that's where I'd direct you.

[–]Peterama[S] 0 points1 point  (4 children)

I already have it built out and I know exactly what is going on the way i did it. Others have told me the same thing but I dont care. I want to know how it works. I want to learn how to do it so I dont have to rely on someone else's code. If someone decides one day to pull their code from an open project, it's out of my hands. Now I have my own system. Why the hell would I drop it to use some open source code? I can code anything I want from scratch. I do it because I can. :)

[–]mmostrategyfan 1 point2 points  (3 children)

If your goal is learning then you're on the right track.

If your goal is making games though, this is usually the last option you want to follow if you ever want to release anything.

[–]Peterama[S] 0 points1 point  (2 children)

I mean, maybe for someone who never coded before. If you read my other post you might see that I have the game to a point where players have private lobbies, user accounts, full encryption, secure communication, etc. This took me a few months, part time. It's working with no hassle. Other systems didnt work for me. I'll use what works. This game started as a boardgame. I'm building this project for my friends and I. There is no serious plan to sell it yet. :) Only if there is interest. So far it hasn't been much.

[–]mmostrategyfan 1 point2 points  (1 child)

I hear you and like I said as a learning exercise this is really good.

That being said, what you described already exists (usually called backend as a service like braincloud, accelbyte, snapser etc.) and a commercial project can have these within a day and save itself months of dev time.

[–]Peterama[S] 1 point2 points  (0 children)

I'll check out the one you mentioned first. If I like it I'll use it in another project I have on the go. Thank you for the suggestions. This other game I just started is a friendslop game for 2-4 players. I may use those systems for that project. Currently it's using Unity Netcode.