Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Websocket between two smartphone

Discussion in 'Multiplayer' started by PhiKirax, Mar 30, 2021.

  1. PhiKirax

    PhiKirax

    Joined:
    Feb 8, 2016
    Posts:
    10
    Hi, do you know if it is possible to communicate between two smartphones by websocket on a 4G or wifi network ?

    you don't care about ip address recovery i know how to do just i would like to know if the connection between two smartphones is possible especially in 4g, or i'm not sure
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    10,809
    The first issue is typically these devices are on a NAT network, which is often the case even when connected to 4G. So acting as a server of any kind is usually not practical for a mobile device unless the two devices were right next to each other connected to the same wifi as each other. The most direct work around for this is to use a relay server. So both smartphones both connect to the relay server as clients, even though one of them can act as the host for the purposes of the game.

    As far as websockets specifically, I don't know, as I typically use UDP for games. But acting as a websocket client, I wouldn't anticipate any issues.
     
  3. PhiKirax

    PhiKirax

    Joined:
    Feb 8, 2016
    Posts:
    10
    It is the reflexion I’ve made, especially since Unity has removed the network package so now we have to do it custom

    finally I just made a virtual router
     
    Last edited: Mar 31, 2021
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,580
    Joe-Censored likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    10,809
    MLAPI was acquired by Unity, and is the official 1st party network API going forward for projects not using DOTS/ECS. But as already mentioned, there are several 3rd party API's available.
     
    luke-unity likes this.
unityunity