Search Unity

WebGL & Other Devices ALL CONNECTED TO SAME SERVER

Discussion in 'Multiplayer' started by ariel-terrani, Jun 10, 2017.

  1. ariel-terrani

    ariel-terrani

    Joined:
    May 15, 2016
    Posts:
    4
    Is it possible to have normal (pc/mobile) clients and WebGL clients connect to the same game?

    I'm new to Unity and just using the built-in NetworkManager and NetworkManagerHUD components for multiplayer. If I select "Use WebSockets" from the NetworkManager on the host, I can connect WebGL client to a game hosted from Standalone, but other stand alone or android clients cannot join that same game. Is that even possible or am I doing something wrong? What if I try doing this?:
    (This script is attached to the NetworkManager)
    Code (csharp):
    1.  
    2. using UnityEngine.Networking;
    3. using UnityEngine;
    4. public class CrossGLSupportAriel : MonoBehaviour {
    5.  
    6.   void Update() {
    7.         NetworkManager.singleton.useWebSockets = !NetworkManager.singleton.useWebSockets;
    8.    }
    9.  
    10. }
    11.  
     
    Last edited: Jun 10, 2017
  2. ariel-terrani

    ariel-terrani

    Joined:
    May 15, 2016
    Posts:
    4
    This doesn't work, the script doesn't work! Seems it can't be changed at runtime.

    Still need help solving this!
     
  3. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Changing the socket type like this wont work. Just use WebSockets. Websockets works for all platforms AFAIK
     
  4. ariel-terrani

    ariel-terrani

    Joined:
    May 15, 2016
    Posts:
    4
    What is AFAIK? Also when I enabled WebSockets, the server would not work for PC downloadable version, only worked on webclient.
     
  5. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    As far as I know.

    This makes the NetworkServer listen for WebSockets connections instead of normal transport layer connections.

    This allows WebGL clients to connect to the server.
    https://docs.unity3d.com/ScriptReference/Networking.NetworkManager-useWebSockets.html
    This tells me that if you host the server using Websockets and all clients including PC clients use websockets they should all be able to connect. Just make everything use websockets