Wrap the data into a request type

This commit is contained in:
2024-09-23 20:05:28 +02:00
parent 58d6ed043e
commit 27c3f7ecd1
3 changed files with 46 additions and 21 deletions

View File

@ -81,14 +81,21 @@ fn main() -> () {
Ok(_) => {}
Err(err) => error!("Processing error: {err}"),
}
if ! worker.is_authenticated() {
if !worker.is_authenticated() {
let msg: WorkerMessages = WorkerMessages::AuthenticateRequest {
login: "williamdes".to_string(),
};
let msg: String = serde_json::to_string(&msg).expect("To serialize").into();
match ws_client.send(msg) {
let msg_string: String = msg.to_string();
match ws_client.send(msg_string) {
Ok(_) => {
worker.authenticated = true;
match msg {
WorkerMessages::AuthenticateRequest { login } => {
worker.authenticated = true; // Anyway, it will kick us if this is not success
info!("Logged in as: {login}")
}
WorkerMessages::GetWorkRequest {} => {}
msg => error!("No implemented: {:#?}", msg),
}
}
Err(err) => error!("Unable to connect to {url}: {err}"),
}