Okay so, I made one last-ditch attempt to answer the questions I had and also find a solution to the issues that I was having in supporting websockets in the web-build of the game, and I figured I’d post this here for anyone else who is struggling.
Moving away from the LLAPI
The first thing I had to do was ditch my reliance on the LLAPI. The documentation states (within the WebGL section of the llapi documentation) that client side websockets ARE supported, however I am 90% convinced now that this is not the case. On the server-side, you are able to set up a websocket socket by simply calling NetworkTransport.AddWebsocketHost (https://docs.unity3d.com/ScriptReference/Networking.NetworkTransport.AddWebsocketHost.html), however, there is no way to connect to this host/socket from the client side while using the llapi. You could obviously use a custom websocket solution here, however my point is that llapi doesn’t provide sufficient websocket support currently. I presume though that this will change in the future.
Also, attempting to implement a custom client-side using a websocket library will mean that you need to be able to decipher unity’s byte arrays. At this level, the arrays never seem to be formatted exactly how you expect which makes it very difficult. Doing this is likely to also break your solution in future updates of unet.
Considering using certain HLAPI elements
I was convinced that unet must support websockets somewhere, since it’s talked about in the documentation. After looking into the HLAPI elements in more detail, I noticed a few settings related to websockets and figured I’d try implementing certain parts of the HLAPI into my solution. I knew that this would add additional layers to my solution (potentially adding overhead) however at this point I had no choice.
Ultimately I managed to get a pretty solid solution using the NetworkClient and NetworkServerSimple classes. The combination of these classes allows for the use of websockets, and using these classes alone allows us to avoid the bloated-ness of the HLAPI (if you don’t need all of the additional functionality).
I used the NetworkClient class as a way to handle the client-side connection and messaging. NetworkServerSimple (as apposed to NetworkServer, which is the more bloated version) was used to set up udp and websocket sockets, and handle incoming peer connections and messaging.
Note however that when testing the NetworkClient from within the editor, calling the NetworkClient.Connect method will ALWAYS try and connect as a udp peer (so trying to connect to a websocket server-side will always fail in the editor, even if WebGL is your selected platform!). When a NetworkClient.Connect is used within a WebGL build however, it will ALWAYS connect as a websocket peer (so in this case you will need to connect to a websocket server-side). This took me a while to figure out…
Getting used to handlers
In the LLAPI, the meat of your business logic will originate from NetworkTransport.Receive or NetworkTransport.ReceiveFromHost. In the HLAPI however, you make use of handlers. A dated example exists here (this code is no longer correct, but the idea is the same): https://docs.unity3d.com/ScriptReference/Networking.NetworkClient.Connect.html. This ads a slight bit of overhead no matter how you implement them (as apposed to the llapi), however the HLAPI requires that you use them. Trying to use the llapi Receive/ReceiveFromHost for example will cause you problems here, because the HLAPI formats the byte arrays in a certain way to be able to identify the type of “message”.
So ultimately, you’ll need to move the meat of your business logic from the Receive/ReceiveFromHost methods into handlers.
Conclusion
As of writing this, websockets are not supported fully in the LLAPI. It is likely that support for websockets in unet will improve over time, however currently if you require the ability to use websockets at a low-level (if you don’t want to use the HLAPI), then at minimum you will need to use the NetworkClient and NetworkServerSimple classes.
Hopefully this helps someone!