3 ms·
AS3 is one of those things where we needed to put in a lot of work just to get basic things working, because the runtime is a hell of a lot stricter[0]. On AS1/
by kmeisthax 4y ago
AS3 is one of those things where we needed to put in a lot of work just to get basic things working, because the runtime is a hell of a lot stricter[0]. On AS1/2 we could hook up a few basic things and have basic games working. Further complicating things was that a lot of under-the-hood things about frame lifecycle are different, in ways that took a while to fully understand.
There's a bunch of work going on with Stage3D that's pretty promising.
Socket support on the other hand is probably not happening since the web doesn't allow arbitrary TCP/IP sockets. You'd need to switch to WebSockets for Ruffle clients - fortunately we support `ExternalInterface` so mixing AS3 and HTML5 code is possible.
[0] AVM1 has no runtime errors aside from infinite recursion and infinite prototypes. This leads to some absolutely ridiculous consequences even for basic operations, like prototype-less objects sorting differently from ones with prototypes.
- noduerme 4y ago> runtime is a hell of a lot stricter interesting... I always thought of AS3 as compile-time strict, which I miss about it. But I forgot all those additional (verbose) runtime errors... > fortunately we support `ExternalInterface` so mixing AS3 and HTML5 code is possible. Out of curiosity... it makes sense that WASM can't open an arbitrary socket, but couldn't there be a uniform wrapper for flash.net.Socket or NetConnection to talk via WebSocket or AJAX? (NetStream / RTMP seems mostly pointless now, since all those apps are long since dead; but NetConnection at the least is critical...) Not to criticize. The work you've done is fantastic!
- kmeisthax 4y agoWrapping 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 ).
- londons_explore 4y ago> Socket support on the other hand is probably not happening since the web doesn't allow arbitrary TCP/IP sockets. You can still do this with the help of an external server. If Ruffle wants to talk to Ruffle, then the external server doesn't need to handle the traffic, and is cheap to run. If Ruffle wants to connect to something else, the external server will proxy the traffic. But even then, running this for the whole world is probably something that could be supported with ad revenue or donations.
- teaearlgraycold 4y agoWouldn’t most other players be on ruffle as well? Seems easy to just have ruffle translate to websockets.
- londons_explore 4y agoWebsockets can only connect from a browser to a server. Webrtc can connect from a browser to another browser, but still requires a server to send a bit of information back and forth to get stuff organised.