Skip to content

Commit

Permalink
Clean up indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jun 5, 2024
1 parent 7336fc1 commit 07346dd
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions app/nativehelper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ fn connect() -> (Sender<OwnedMessage>, JoinHandle<()>) {
}
}
});
return (tx, receive_loop);

return (tx, receive_loop);
}

fn handle_message(nl_token: &String, tx: Sender<OwnedMessage>, message: String) {
Expand All @@ -123,47 +123,47 @@ fn handle_message(nl_token: &String, tx: Sender<OwnedMessage>, message: String)
}

fn authenticate(tx: Sender<OwnedMessage>, nl_token: String) {
match Client::init() {
Ok((client, single)) => {
match Client::init() {
Ok((client, single)) => {
let called = Arc::new(AtomicBool::new(false));
let callback_called = called.clone();

let (_ticket_handle, session_ticket): (steamworks::AuthTicket, Vec<u8>) = client.user().authentication_session_ticket();
let _callback =
client.register_callback(move |session_ticket_response: AuthSessionTicketResponse| {
//if session_ticket_response.ticket == ticket_handle {
println!("Ticket Response Result: {:?}", session_ticket_response.result);
callback_called.store(true, Ordering::Relaxed);
// println!("Ticket : {:?}", session_ticket_response.ticket);
// println!("Ticket Response: {:?}", session_ticket);

let message = OwnedMessage::Text(format!("\
{{\
\"id\": \"15fb0ffb-7b18-48d2-89a3-39b1ce4b2645\",\
\"method\": \"app.broadcast\",\
\"accessToken\": {:?},\
\"data\": {{\
\"event\": \"steamAuthToken\",\
\"data\": {:?}\
}}\
}}", nl_token, &session_ticket));
match tx.send(message) {
Ok(()) => (),
Err(e) => {
println!("Websocket send error: {:?}", e);
}
}

});
for _ in 0..100 {
single.run_callbacks();
if called.load(Ordering::Relaxed) {
return;
}
::std::thread::sleep(::std::time::Duration::from_millis(50));
}
},
Err(_) => {
let (_ticket_handle, session_ticket): (steamworks::AuthTicket, Vec<u8>) = client.user().authentication_session_ticket();
let _callback =
client.register_callback(move |session_ticket_response: AuthSessionTicketResponse| {
//if session_ticket_response.ticket == ticket_handle {
println!("Ticket Response Result: {:?}", session_ticket_response.result);
callback_called.store(true, Ordering::Relaxed);
// println!("Ticket : {:?}", session_ticket_response.ticket);
// println!("Ticket Response: {:?}", session_ticket);

let message = OwnedMessage::Text(format!("\
{{\
\"id\": \"15fb0ffb-7b18-48d2-89a3-39b1ce4b2645\",\
\"method\": \"app.broadcast\",\
\"accessToken\": {:?},\
\"data\": {{\
\"event\": \"steamAuthToken\",\
\"data\": {:?}\
}}\
}}", nl_token, &session_ticket));
match tx.send(message) {
Ok(()) => (),
Err(e) => {
println!("Websocket send error: {:?}", e);
}
}

});
for _ in 0..100 {
single.run_callbacks();
if called.load(Ordering::Relaxed) {
return;
}
::std::thread::sleep(::std::time::Duration::from_millis(50));
}
},
Err(_) => {
println!("Steam not available");
let message = OwnedMessage::Text(format!("\
{{\
Expand All @@ -181,10 +181,10 @@ fn authenticate(tx: Sender<OwnedMessage>, nl_token: String) {
}
}
}
}
}
}

fn main() {
let (_tx, receive_loop) = connect();
let (_tx, receive_loop) = connect();
let _ = receive_loop.join();
}

0 comments on commit 07346dd

Please sign in to comment.