3 ms·
Wrapping Socket/NetConnection in WebSockets requires a cooperating server. Same for PeerConnection, which will also need all-Ruffle swarms or some kind of peer
by kmeisthax 4y ago
Wrapping Socket/NetConnection in WebSockets requires a cooperating server. Same for PeerConnection, which will also need all-Ruffle swarms or some kind of peer forwarding protocol for mixed Ruffle/FP swarms. So we'd have to have some kind of config option for "route this Socket endpoint to this WebSockets endpoint".
- noduerme 4y agoPeerConnection, clearly, would be very hard. For NetConnection I was just thinking about basic REST calls. Almost all my AS3 game code starts with long polling to APIs and upgrades to a Socket. The trouble with ExternalInterface (if I even remember) is that it makes you define custom methods on the Javascript side to link to active AS3 methods... I guess what I mean is could there be a common wrapper that sets up a web worker which can open either WebSockets or `fetch` / XMLHttpRequests arbitrarily and stream messages back and forth to a Ruffle class that implements all of the normal AS3 socket / NetConnection functions? Like, browser middleware in a worker to do all the outbound connections? I don't mean opening inbound sockets -- that was never really a feature of AS3 except through RTMP, and that's not what I'm referring to. I mean connecting up to server sockets. Maybe I'm not making sense or I'm too far out of this and need to just start tinkering ;)
- knome 4y agoIt might be easiest to allow the site running ruffle to provider a websocket via a call on the object. If the site hasn't setup the websocket to use, then the code can pretend whatever server the flash object is asking for just isn't reachable. If the javascript interface is just a packet shunt callback, then it's a bit slower, but the host could provide a local bit of javascript implementing a fake server if they wished ( to maybe fake a high score website or something long since gone that the flash thing required ).