Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

So... this is what I need. Any Ideas how should I do it?

Discussion in 'Multiplayer' started by shanytopper, Dec 11, 2017.

  1. shanytopper

    shanytopper

    Joined:
    Aug 2, 2013
    Posts:
    7
    Ok, so I see my previous question was not specific enough, so I'll try to be as specific as I can:

    For a game I am building, I need to use some multiplayer networking solution, and I don't know what to use.
    Here is the thing. The server is built based on .Net, and is not Unity. Also, I need to host the server myself, and not some service such as uNet or Photon.

    Also, I need to have the following critical features:

    a- The communication layer has to be full duplex, as the server will constantly send the client information. This, for example, kill the option to use WCF (unity does not support duplex WCF) or WebAPI (is request-respose based).

    b- I need to be able to send complex data structures. Those are my own classes that need to be shared between the client and the server (DTO).

    c- It has to be scalable. That is, as I don't know how many clients are going to be playing at the same time, I need to be able to easily adjust for more players as the game (hopefully) become popular.

    d- High performance. same with scalability really. if a single server can only serve a small amount of users, its not very usefull for me, for obvious reasons.

    Features I do NOT need:

    a- Hosting. Like I wrote above, I will host the game myself. (maybe on Amazon or Azure, yet to be determined, but not the point)

    b- Syncing to Unity types and GameObjects. The information I send is not directly mapped to anything "Unity specific", so all kind of cool solution that sync up information such as GameObjects position as rotations are mostly useless to me.



    Here are some solutions I tried to investigate (I might have mistakes here, this is just the results of the research I made. If I am wrong on something, let me know):

    uNet: From what I managed to gather, uNet is based on the concept of client-as-a-host. That is, one of the clients is the "authority". This is very far from what I need, which is that the clients will connect to a dedicated server.

    Photon: From what I managed to understand, just like uNet, this is based on the idea of a single Unity application being the authority. The biggest difference is that Photon allows this application to be "headless" and run on the Photon hosting servers. This is, again, very far from what I require, which is, like I said, to host my own .Net server (and not use Unity on the server side)

    WCF: While Unity support connecting to WCF services, this is true only for the most basic ones. using Duplex connections or DataContracts are currently impossible with Unity.

    WebAPI: As a RESTful solution, it is by definition meant to be used with a request-response approach and does not support duplex connection.

    Sockts: This CURRENTLY seems like the most promising option, as it allows for duplex connection on a self hosted .Net server, however, this seems to mean I need to do pretty much everything by myself. This is extra difficult as for some reason it seem like there is very bad (and/or old) documentation on the subject.

    Socket.IO: A very popular solution I seen is using Socket.IO, which I understand can be very good, except... Socket.IO server run on Node.js, and not on .Net. So that makes its a problem. (in theory, I guess I can make the Node.js server as some sort of "proxy" between the .Net server and the clients, but it seems to me like a bad solution)


    So..... Any ideas on what should I do?

    And please, don't give my answers of "use X", or "you are wrong about Y". Be specific, give me links to documentation / guides / tutorials on how to do things.

    Thanks.
     
  2. Chris-HG

    Chris-HG

    Joined:
    Aug 10, 2012
    Posts:
    63
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Unity can build headless and UNET can be used as a dedicated server. There is also a UNET dll that you can request so you can build for it outside of Unity. Transferring complex data structures will require writing your own serialize/deserialize functions. I haven't used the others you mention, so can't comment if UNET is better or worse than them.