c80k / capnproto-dotnetcore

A Cap'n Proto implementation for .NET Standard and .NET Core
Other
145 stars 27 forks source link

WebGL RPC Support? #56

Open anchpop opened 3 years ago

anchpop commented 3 years ago

Related to #35 - I'm using this library with Unity, and everything works great in the editor and when building for windows, but when building for webGL I get this error:

genomics_viz_webgl.framework.js:3412 SocketException: mono-io-layer-error (0)
  at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 

image

It happens when running using var client = new TcpRpcClient();. Which surprises me, because new TcpRpcClient() doesn't attempt to connect anywhere. I wonder what could be causing this (because to be honest I can't make heads or tails of the error message). I think its use of the TcpClient class that's messing it up.

From the Unity docs:

Note that you cannot use .NET networking classes, because JavaScript code does not have direct access to IP Sockets to implement network connectivity.

Which means I need to find a way to implement the Tcp client in a way that doesn't use IP Sockets. I think this necessitates using websockets. Any tips?

cupen commented 1 year ago

I like your idea. But WebGL cannot use TCP, just use WebSocket instead of.