websocket
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#![allow(clippy::needless_return)]
|
||||
|
||||
mod app;
|
||||
mod client;
|
||||
mod config;
|
||||
mod dirs;
|
||||
mod icon;
|
||||
@@ -18,7 +19,8 @@ use oauth::{start_code_listener, start_code_to_token};
|
||||
use pipe::Pipe;
|
||||
use state_machine::Event;
|
||||
use tokio::task::JoinSet;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, Layer};
|
||||
|
||||
pub static AVAM_APP_ID: &str = "AvamToast-ECEB71694A5E6105";
|
||||
pub static BASE_URL: &str = "https://avam.avii.nl";
|
||||
@@ -42,7 +44,8 @@ async fn main() -> Result<(), anyhow::Error> {
|
||||
|
||||
init_logging()?;
|
||||
|
||||
let (event_sender, event_receiver) = tokio::sync::broadcast::channel(1);
|
||||
// let (socket_sender, socket_receiver) = tokio::sync::broadcast::channel(1);
|
||||
let (event_sender, event_receiver) = tokio::sync::broadcast::channel(10);
|
||||
let args = Arguments::parse();
|
||||
|
||||
if handle_single_instance(&args).await? {
|
||||
@@ -81,7 +84,7 @@ async fn main() -> Result<(), anyhow::Error> {
|
||||
|
||||
// // Start the code listener
|
||||
let receiver = event_receiver.resubscribe();
|
||||
let (pipe_sender, pipe_receiver) = tokio::sync::broadcast::channel(100);
|
||||
let (pipe_sender, pipe_receiver) = tokio::sync::broadcast::channel(10);
|
||||
futures.spawn(start_code_listener(pipe_sender, receiver));
|
||||
|
||||
// Start token listener
|
||||
@@ -90,6 +93,20 @@ async fn main() -> Result<(), anyhow::Error> {
|
||||
let receiver = event_receiver.resubscribe();
|
||||
futures.spawn(start_code_to_token(c, pipe_receiver, sender, receiver));
|
||||
|
||||
// Start the websocket client
|
||||
// The socket client will just sit there until TokenReceivedEvent comes in to authenticate with the socket server
|
||||
// The server needs to not accept any messages until the authentication is verified
|
||||
let sender = event_sender.clone();
|
||||
let receiver = event_receiver.resubscribe();
|
||||
futures.spawn(client::start(sender, receiver));
|
||||
|
||||
// We need 2 way channels (2 channels, both with tx/rx) to send data from the socket to simconnect and back
|
||||
|
||||
// Start the simconnect listener
|
||||
// The simconnect sends data to the webscoket
|
||||
// It also receives data from the websocket to do things like set plane id and fuel and such things
|
||||
// If possible even position
|
||||
|
||||
// Start the Tray Icon
|
||||
let c = config.clone();
|
||||
let sender = event_sender.clone();
|
||||
@@ -230,7 +247,9 @@ fn init_logging() -> Result<(), anyhow::Error> {
|
||||
#[cfg(not(debug_assertions))]
|
||||
let file = File::options().append(true).open(&log_file)?;
|
||||
|
||||
let fmt = tracing_subscriber::fmt::layer();
|
||||
let fmt = tracing_subscriber::fmt::layer().with_filter(tracing_subscriber::filter::filter_fn(
|
||||
|metadata| metadata.level() < &Level::TRACE,
|
||||
));
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
let fmt = fmt.with_ansi(false).with_writer(Arc::new(file));
|
||||
|
Reference in New Issue
Block a user