Giter Site home page Giter Site logo

Convenient way to end a session about bevy_ggrs HOT 5 OPEN

gschup avatar gschup commented on July 18, 2024 2
Convenient way to end a session

from bevy_ggrs.

Comments (5)

johanhelsing avatar johanhelsing commented on July 18, 2024 1

Btw, my workaround for this is to create a newtype around an Arc<RwLock>, so i don't actually give the socket to ggrs

from bevy_ggrs.

johanhelsing avatar johanhelsing commented on July 18, 2024

Thanks for reporting, I'd like a convenient way to do this as well.

I think it's best if session starting and closing mirrors each other. So perhaps best to change how we start from inserting a resource to commands as well. Perhaps:

let session = session_builder
    .start_p2p_session(socket)
    .expect("failed to start session, check config");

commands.start_session(session);

Or perhaps take a session_builder and socket instead?

commands.start_p2p_session(session_builder, socket);

from bevy_ggrs.

ndev-rs avatar ndev-rs commented on July 18, 2024

I think it's best if session starting and closing mirrors each other. So perhaps best to change how we start from inserting a resource to commands as well. Perhaps:

let session = session_builder
    .start_p2p_session(socket)
    .expect("failed to start session, check config");

commands.start_session(session);

That would be a nice abstraction. Would it be possible to have the socket returned to us when we end the session? Something like:

let socket = commands.end_p2p_session()
    .expect("failed to return socket");

from bevy_ggrs.

johanhelsing avatar johanhelsing commented on July 18, 2024

Not with commands, no. It could perhaps be put into a resource where we could collect it... Not the nicest api, though

from bevy_ggrs.

ndev-rs avatar ndev-rs commented on July 18, 2024

Not with commands, no. It could perhaps be put into a resource where we could collect it... Not the nicest api, though

Yeah, that sounds pretty ugly. I like your idea of having the api work entirely thru commands, but perhaps there could be a separate way to take the socket which would make the session inactive until we clean it up via commands. Though that's probably a separate Issue.

let socket = session.take_socket();
commands.end_p2p_session();

from bevy_ggrs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.