Search Unity

Realtime communication between cross-platform Unity apps

Discussion in 'Multiplayer' started by abhilash-c, Oct 6, 2018.

  1. abhilash-c

    abhilash-c

    Joined:
    Jul 30, 2018
    Posts:
    3
    Hello,

    I am looking for real-time communication in Unity3D. The idea is to exchange messages - primitivestypes, serialized objects, etc. between different Unity3D (cross-platform) apps. I have came across many 3rd party services provider. I am planning to implement my own solution since my target audience is enterprise and not for gaming.

    On a very high-level,
    1. Every app connects to the server (after authentication)
    2. Once approved, they can start exchanging messages
    I have used NetworkServer/Client and Messages extensively earlier. I would like to know, is there any better and suggested approaches to this. Is it worth creating my own server setup for this purpose.

    What protocols should I refer to get started for this? Is it worth the time and effort?
    Any help will be appreciated.

    Thank you.
     
  2. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,124
    I think it can be a good option if the workload can be handled using a unity based server. Otherwise probably a multi-threaded or distributed solution either based on services or your code outside of Unity is needed.

    However if server costs are not an issue and a single threaded scripting runtime is enough to handle the work load on each server instance, I see no reason, why you should not use what you already know and used before as well.

    Disclaimer: I sell such a product (distributed game backend)
     
  3. abhilash-c

    abhilash-c

    Joined:
    Jul 30, 2018
    Posts:
    3
    Hello Ashkan_gc, thank you for the reply. Can you please guide me through the steps - technologies, protocols, etc. required to setup such a server. Of course, I won't ask you the source code. But, any guidance would be highly appreciated.
    Thank you.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    Your audience is using a Game Engine.
    You don't have to create an enterprise-customer networking solution just because existing ones are sold primarily for gaming purposes. Unless you want to and get paid to implement this .. don't.

    Make up your mind if you want a Unity instance to run as server or if you want that independent from Unity. Then pick a random somewhat suitable-looking solution and try it.
     
  5. abhilash-c

    abhilash-c

    Joined:
    Jul 30, 2018
    Posts:
    3
    Let me elaborate a bit on real-time communication with a simple use-case.

    Assume, I am creating a messaging app in Unity. To build this app, it is very crucial for me to send the messages to all the participants in a chat without any delay. I am referring to similar kind of real-time communication. How can I exchange information to all the participants in a session in realtime without any delay. Do you have any suggestions for that?

    Earlier I have used NetworkDiscovery/NetworkServer/NetworkClient but for that to work, all the participant needs to be on same network. I am looking for an implementation, I can exchange data to a remote participant over the internet.

    It would be great if you could suggest some solutions to this, instead of saying - pick a random one?

    Hope this clarifies what I am trying to achieve.
     
  6. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,124
    Take a look at @tobbias's company's photon cloud. Should do what you want unless you hit the limits on their service which is very unlikely based on what you are describing.
    Another option is gamesparks real-time messaging but due to heavy javascript usage on the server side I don't like it that much.

    These solutions basically create a relay server which all of your clients connect to, then exchange messages between them.

    As tobiass said, you should not implement a custom solution if you don't need to.


    However if you want to implement
    You will need to make a socket server and a suitable protocol which if you don't know anything about, you should probably not do it.
    the protocol of your serialization might be binary/any text based on like JSON/XML and the transportation protocol can be raw TCP, WebSocket or use higher level libs like zeroMQ , again doesn't seem to be needed at all for your case