RedpointArchive / netcode.io-browser

Browser extensions which enable the use of netcode.io (secure UDP) prior to adoption in web browsers
293 stars 22 forks source link

Add support for subscribing to client state changes. #3

Closed GlaireDaggers closed 6 years ago

GlaireDaggers commented 6 years ago

This pull request would add support for subscribing to state changes by adding a new "stateChange" event type to the client.addEventListener function. As an example, this could be used to easily detect when a client has connected to a server without having to poll the client's state.

GlaireDaggers commented 6 years ago

Could also potentially make a change so that this also sets a state field on the client object on the JS side, so then you could also just check client.state without having to do an async poll.

hach-que commented 6 years ago

Can you make sure everything is using spaces and formatted correctly? Thanks

GlaireDaggers commented 6 years ago

Got it. Should be fixed now.

hach-que commented 6 years ago

Thanks!

hach-que commented 6 years ago

(This won't be available immediately as I need to bump the extension version number, update on store listing and update the GitHub release with the new helper, probably will happen on the weekend though)