johanhelsing / johanhelsing.github.io

Johan Helsings github page
1 stars 0 forks source link

Introducing Matchbox #11

Open johanhelsing opened 2 years ago

Jobieskii commented 2 years ago

Hi, I've been following your extreme bevy series and I'm using it to make a little test game myself. However I'm stuck and was wondering if you could help me out. I need RNG, which needs to be seeded from some common random value. So far, I've tried to generate the seed from peerIds, but the functions available only give the remote player's id. Alternatively there could be a separate stage where matchbox_server generates the seed and shares but that would require some tinkering. Anyway, maybe you've thought about something like this and there is a solution I'm not seing.

johanhelsing commented 2 years ago

So far, I've tried to generate the seed from peerIds, but the functions available only give the remote player's id.

As I started reading your post, this is what I was actually about to suggest.

This is just an oversight on my part, it's not intentional that WebRtcNonBlockingSocket doesn't have a way to get your own id. After all, the underlying type, WebRtcSocket has it. Created an issue for it: https://github.com/johanhelsing/matchbox/issues/22

That said, you could get what you want using existing APIs by adding more fields to your input and have the players exchange it that way.

Alternatively there could be a separate stage where matchbox_server generates the seed and shares but that would require some tinkering.

I think a more general solution to send data outside of bevy_ggrs would be very useful, for instance if you'd want some kind of chat room in your lobby, that's currently tricky to do.

Feel free to create an issue for it in the matchbox repo, and we can continue the discussion there :)

Jobieskii commented 2 years ago

Thanks for the quick reply. I'll hold off implementing random seeds then for now.

Regarding the second part of your response. Are you saying that sending arbitrary data could be something you see done with matchbox / matchbox_server sometime in the future, or that I should look for a completely separate solution, with two webSockets servers?

alanpoon commented 2 years ago

@Jobieskii I am using Wasmcloud with nats-server (websocket). Bevy's world can be compiled into wasmcloud's actor. My bevy can connect to NATS.

johanhelsing commented 2 years ago

Thanks for the quick reply. I'll hold off implementing random seeds then for now.

So I fixed the issue with not being able to get your own id, so with matchbox main branch (and soon to be released 0.4) this is now possible.

Regarding the second part of your response. Are you saying that sending arbitrary data could be something you see done with matchbox / matchbox_server sometime in the future, or that I should look for a completely separate solution, with two webSockets servers?

I'm a bit conflicted about this... On the one hand, it would be really convenient for games if they could broadcast messages through the signaling server, say to implement chat in the lobby. On the other hand, one of the nice things about the current architecture, is that it's really cheap since you only use the server to bootstrap direct connections.

At least in some setups you'd probably want some third service anyway (if you want to do more complex kinds of matchmaking, honor preferred/banned maps, consider elo etc.). I feel like that sort of logic is very dependent on the game in question and definitely out of scope for matchbox.

I opened an issue for it in the matchbox repo, let's continue the discussion there: https://github.com/johanhelsing/matchbox/issues/25