Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use Lobby to pair #1

Open
vishalkrishnads opened this issue Mar 7, 2023 · 2 comments
Open

Can't use Lobby to pair #1

vishalkrishnads opened this issue Mar 7, 2023 · 2 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@vishalkrishnads
Copy link
Member

Since Lobby can't contain a db field, it is impossible to pair a vehicle to it's user through it. The application requirements state that a user & vehicle should be able to use a single websocket connection to execute the pair. This is necessary to implement QR code pairing at the client side.

  • The default() method doesn't support args

    impl Default for Lobby {
        // default() can't take args
        fn default(db: Database) -> Lobby {
            Lobby {
                db_instance: db,
                sessions: Hashmap::new(),
                rooms: Hashmap::new()
            }
        }
    }
  • There is no way to make the default() method async in Lobby, or anywhere basically.

    impl Default for Lobby {
        // this throws an error
        async fn default() -> Lobby {
            // async code to spin up a new connection to db
            Lobby {
              db_instnace: <db_object>,
              sessions: Hashmap::new(),
              rooms: Hashmap::new()
            }
        }
    }
@vishalkrishnads
Copy link
Member Author

I also tried using actix_web::rt::spawn() to move the database operations directly into Handler<Connect> for Lobby, but can't access the self of Lobby inside the spawned closure.

actix_web::rt::spawn(async {
    // make db updates here
    self.send_disconnect(&*message, &msg.self_id, CloseCode::Normal);
});

This method would've worked as we could check everything before initiating the pair.

@vishalkrishnads vishalkrishnads added the bug Something isn't working label Mar 7, 2023
@vishalkrishnads vishalkrishnads mentioned this issue Mar 7, 2023
@vishalkrishnads
Copy link
Member Author

We've concluded that it's better to leave this as is until UI is complete. If this hinders the UX, then we'll deal with it then.

@vishalkrishnads vishalkrishnads added the wontfix This will not be worked on label Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant