Hello guys, i want to create an authoritative server for a game that dont need to sync gameobjects in real time. Basically this:
Send and recive messages from clients
Access to SQL DB
Connection with other servers (login, matchmaking, etc)
This is enough to make my small game, but i want to know if is better to use any Unity network system or to use C# Async sockets on .Net to recieve connections from Unity clients directly.
My doubt is that beeing a simple console server that dont need any 3D space raycast/physics/whatever, writting it on Unity dont use more resources than needed or have less potential than directly a C# server?
Thanks in advance.
If it’s not realtime, you could also use the WWW class in the client and any HTTP based server. It’s not about speed, so you can fallback to a really simple tech that rarely fails and can be programmed server-side in any language that you or a server dev knows.
hmm yes basically is a turn-base card game for mobile, so i want a login server, Matchmaking server and game server. Game server will control turn flows, get cards data from SQL database, recieve players actions, calculate the card combat and send results. Is something really simply. WWW seems enough so i will do some tests.
Hmm there is a problem with a HTTP server, the comunication from server to client have to be “forced” by the client, this mean that every client have to ask the server, for example, every second if there is something new, because an HTTP server cannot directly send info to a client. Example:
- User A move a chess piece.
- Server get the petition to move the piece, check if posible, store the movement, calculate results, and send to User A and User B the result.
in HTTP, to do this, User B have to be asking for updates all the time sure?
Right. With HTTP, the clients have to poll for news. You don’t have to use a fixed poll rate, however. Poll 5…10 seconds when nothing really happens.
The benefit of HTTP is purely in the simplicity to code, run and manage. If your players complain about speed you can switch to another protocol later on.
I don’t think Unity has out-of-the-box access to SQL Databases. You may have to use PHP, unless I’m mistaken?
I will try ASP MVC 5 as server side. If i am correct, to send data i should use WWWForm but to recieve data i want someone to confirm this:
I create an ASP page that need a Session Key (identifier from user that logged before and stored on unity client)
With this Session key, the ASP page calculate whatever or connect to SQL and recieve data. This data is represented as HTML text in the page.
Unity3D client, parse the HTML text to take data.
Is there a better way to send data back to Unity client than writing it on as HTML text and parse it on Unity once it downloaded the page?
Thanks in advance
Rather than having to attempt to parse an HTML page, you could look into the use of JSON serialization - it should suit your needs much better.
hmm so is an option too to write an XML file as output? i never worked with json 
Why are you using HTML or PHP for networking? Why not use Unity’s Built in Networking or if your targeting more then 64 player matches then use something like uLink, KBEngine, Photon, ect?
You can use unity’s built in www to poll any http backend - rails, php, .net, node.
Using json is a great way to go - much easier than parsing html.
Depending on your needs, a custom backend can give you more flexibility than something like photon.
Especially if you have experience writing web db backend servers…