use origin_sdk::{
protocol::{
game::GetAllGameInfo,
profile::GetProfile,
system::{GetConfig, GetInternetConnectedState},
},
sdk::{ClientConfig, OriginSdk, ORIGIN_SDK_PORT},
};
use std::error::Error;
use tracing::info;
use tracing_subscriber::{fmt, EnvFilter};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
fmt()
.with_env_filter(EnvFilter::new("trace"))
.try_init()
.unwrap();
let game = ClientConfig {
content_id: "Origin.OFR.50.0001000".to_string(),
language: "en_US".to_string(),
multiplayer_id: "1026480".to_string(),
title: "Mirror's Edge™ Catalyst".to_string(),
version_override: None,
};
let (client, mut event_rx) = OriginSdk::connect(game, ORIGIN_SDK_PORT).await?;
let _event_handle = tokio::spawn(async move {
while let Some(event) = event_rx.recv().await {
info!("Received event from channel");
info!("{:#?}", event);
}
});
let state = client.request(GetInternetConnectedState {}).await?;
info!("Connected to the internet?: {}", state.connected);
let profile = client.request(GetProfile { index: 0 }).await?;
info!("Profile: {:#?}", profile);
let config = client.request(GetConfig {}).await?;
info!("Config: {:#?}", config);
let res = client.request(GetAllGameInfo {}).await?;
info!("Games: {:#?}", res);
tokio::signal::ctrl_c().await?;
Ok(())
}