amethyst / editor-core

Crate that allows an Amethyst game to communicate with an editor.
Other
44 stars 10 forks source link

Improved UDP socket binding #1

Open randomPoison opened 6 years ago

randomPoison commented 6 years ago

Currently we require that the application logic manually create and bind a UDP socket and add it to the world as a resource. This gives the user control over what port the socket is bound to, but ultimately exposes UDP as an implementation detail that we don't want to finalize on.

Instead, we should have the EditorSyncSystem create its own UDP socket, and add a way to configure which port it binds to. By default it should let the system decide what port it binds to (by binding to 0.0.0.0:0), but allow the user to specify a different port/address to bind to. It might also be good to allow the user to override the default port via an environment variable.

randomPoison commented 6 years ago

I've setup EditorSyncSystem to automatically create its own UdpSocket and bind it to 0.0.0.0:0 (d87d397), which resolves the most immediate issues. It would still be good to add a couple options for configuring which address the socket binds to, though:

Both of these should be fairly easy to implement, and I'd be happy to mentor anyone interested in making the contribution 🙂

randomPoison commented 6 years ago

Another good thing to let the user configure would be the address the game sends it's data to, i.e. which address the editor is listening on. Currently it's hard-coded to send to 127.0.0.1:8000, which is what the Electron editor is listening on.