NetworkTransport.Connect and WebGL, how does it work?

So using LLAPI, to make a connection using NetworkTransport we call the following functions:

On Server:

int hostId = NetworkTransport.AddHost(topology,8888);

On Client:

int hostId = NetworkTransport.AddHost(topology); //no port number
myConnectionId = NetworkTransport.Connect(hostId, “127.0.0.1”, 8888, 0, out error);

but how do we make a connection using Websockets for WebGL?

I know that NetworkTransport.AddWebsocketHost is only called on the server so in that case what hostID do I pass into NetworkTransport.Connect for the WebGL client?

The samples / docs are really unclear.

Ian

Figured this out…

Just used:

int hostId = NetworkTransport.AddHost(topology,0)

Had to look into the NetworkClient source to figure this out though. Also, I’m guessing WebSockets only works as a connection method when building for WebGL?

Thank you @ian_facepunch ! Years later this answer proved useful to us as well :wink: