lucaspoffo / renet

Server/Client network library for multiplayer games with authentication and connection management made with Rust
Apache License 2.0
662 stars 68 forks source link

bevy server and client better connect and disconnect for shutdown or close connect? #92

Closed Lightnet closed 1 year ago

Lightnet commented 1 year ago

Is there better way to handle switch server and client? Meaning to host the server and disconnect and join another server without need to start app. Not sure where it close network to clear up the data.

I look into the code a bit there no shutdown or disconnect from server or client. There should be clean up for those config?

Or I could be wrong. Need to single plugin just need to pass insert_resource for server and client to alt for testing. As there remove resource to handle close connection?

lucaspoffo commented 1 year ago

Using bevy_renet, to host a server, close it, and connect to another server can be achieved by:

  1. Make sure you have both Server and Client plugins added (the sends/receives are executed only if the correct resources exist, so no problem to have both)
  2. To close the server, simply remove the RenetServer and NetcodeTransportServer resources
  3. Create and add new RenetClient and NetcodeTransportClient resources
lucaspoffo commented 1 year ago

If you have any problem trying to achieve this you can reopen it. But it is possible to do what you described following the steps above.