lemunozm / message-io

Fast and easy-to-use event-driven network library.
Apache License 2.0
1.12k stars 75 forks source link

Planning to support web/wasm? #11

Closed erlend-sh closed 3 years ago

erlend-sh commented 3 years ago

Do you intend to eventually support browser games or is that out of scope?

Naia achieves this by using webrtc-unreliable.

lemunozm commented 3 years ago

Yes! One of the next steps is to give support to Websockets

erlend-sh commented 3 years ago

Cool! Does that extend to your asciiarena demo game as well? AFAIK tui-rs doesn’t run on the web. You’d need to use something like bracket-lib instead.

lemunozm commented 3 years ago

Does that extend to your asciiarena demo game as well?

That's precisely the point 😃 . I want to make a frontend abstraction for asciiarena to support different frontends (because as you say, tui-rs, only works for the terminal). When I finish the game to work fine, I want to make the port to wasm :)

And yes, probably this will be the chosen library. I saw the tutorial book about rltk (the now bracket-lib) and it's awesome!

lemunozm commented 3 years ago

I didn't know that bracket-lib also supports crossterm, I have to look it deeply, but if it fits well, with a simple change of tui by bracket it will remain works in terminal and web (and others). Thanks for the recommendation!

erlend-sh commented 3 years ago

I want to make a frontend abstraction for asciiarena to support different frontends

Nice! We’re already doing that in the bracket-based Shotcaller. We also intend to make it networked, following a closer evaluation of our options in about a month. If by that time you’ve had a chance to write a bit about how message-io compares to the other netcode libraries out there that’d be immensely useful.

The ones I’m aware of are:

lemunozm commented 3 years ago

I'm glad to hear that you're valuing using message-io.

I knew about these other libraries but I did not use them (maybe I an wrong in some point), but, from my understanding:

erlend-sh commented 3 years ago

Super helpful! 🙏

What we’re doing would probably work fine with a pretty simple tcp layer.

Also very important to note that the most important thing for me right now as a game designer and publisher is to just see the core idea of the game in the most fully realized state possible at minimum cost. All I want from a netcode library at this stage is to let me prototype the online experience of the game as easily as possible. If it doesn’t scale past 50 or even just 2 concurrent players, that’s fine by me. As long as I can play online with one other person, that covers the bare minimum most needed right now.

lemunozm commented 3 years ago

Then, probably message-io (in the current state) fits well for your purposes 😃 . I hope that when you have mature your game, message-io can be also mature with wasm support, laminar, and other cool features!

lemunozm commented 3 years ago

From version v0.7.1 message-io has WebSocket working for normal and secure mode

entropylost commented 3 years ago

@lemunozm Is it possible to use the websocket on the client side (web) as a direct interface to web-sys? It seems like this is just for the server right now.

lemunozm commented 3 years ago

Hi @iMplode-nZ,

if I understand you well, yes. I have to add an example working with wasm but websocket should work in both, client and server sides. Currently there is a ping-pong example that can be configured to use Websocket as client side.

If you refer to use the Websocket found in web-sys to communicate with a websocket server in message-io. I have not tested, but should work also.

entropylost commented 3 years ago

Thanks. Maybe say this in the readme as its rather confusing?

lemunozm commented 3 years ago

Although you can use WebSocket in message-io from the client-side, it will not run it the web since tungstenite-rs do not work with wasm.

Feature tracking to archieve this: https://github.com/lemunozm/message-io/issues/100