Test and fix steam event system
This commit is contained in:
parent
17c61907a9
commit
4724576f72
7 changed files with 16 additions and 9 deletions
|
@ -24,4 +24,3 @@ For building on another Linux PC, Rust toolchain `x86_64-unknown-linux-musl` mus
|
|||
### Distribution
|
||||
|
||||
IDK, maybe a bit of custom spins as well as a barebones offering from me
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ jmespath = { version = "0.3", features = [ "sync" ] }
|
|||
regex = { version = "1" }
|
||||
|
||||
# logging
|
||||
log = { version = "0.4", features = ["max_level_debug", "release_max_level_warn"] }
|
||||
log = { version = "0.4" }
|
||||
simplelog = { version = "0.12" }
|
||||
|
||||
[profile.release]
|
||||
|
|
|
@ -251,6 +251,6 @@ pub struct SteamAppLifetimeNotification {
|
|||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct SteamGameAction {
|
||||
pub param0: usize, // idk what this is supposed to indicate
|
||||
pub gameID: usize,
|
||||
pub gameID: String, // almost definitely a valid integer
|
||||
pub action: String, // idk what possible values are
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ fn main() -> Result<(), ()> {
|
|||
let cli_args = cli::CliArgs::cli();
|
||||
let log_filepath = cli_args.log.unwrap_or_else(|| format!("/tmp/{}.log", consts::PACKAGE_NAME).into());
|
||||
WriteLogger::init(
|
||||
LevelFilter::Off,
|
||||
LevelFilter::Debug,
|
||||
Default::default(),
|
||||
std::fs::File::create(&log_filepath).expect(&format!("Failed create log file {}", log_filepath.display()))
|
||||
).unwrap();
|
||||
|
@ -33,7 +33,7 @@ fn main() -> Result<(), ()> {
|
|||
.register_blocking("get_items", api::get_items(sender.clone()))
|
||||
.register("on_javascript_result", api::on_javascript_result(sender.clone()))
|
||||
.register("on_update", api::on_update(sender.clone()))
|
||||
.register("on_event", api::on_event(sender.clone()))
|
||||
.register("on_steam_event", api::on_event(sender.clone()))
|
||||
.register_blocking("reload", api::reload(sender.clone()));
|
||||
let _exec_handle = executor.spawn();
|
||||
instance.run_blocking()
|
||||
|
|
|
@ -116,6 +116,15 @@
|
|||
"element": "result-display",
|
||||
"title": "JS Test says",
|
||||
"result_of": 9
|
||||
},
|
||||
{
|
||||
"element": "event-display",
|
||||
"title": "Now Playing",
|
||||
"event": "game-start",
|
||||
"on_event": {
|
||||
"action": "json",
|
||||
"jmespath": "join(' ', [action, to_string(gameID)])"
|
||||
}
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
|
|
|
@ -127,5 +127,5 @@ export async function onJavascriptResult(id: number, value: any): Promise<boolea
|
|||
}
|
||||
|
||||
export async function onSteamEvent(data: CSteamEvent): Promise<boolean> {
|
||||
return (await call_backend("on_javascript_result", [data]))[0];
|
||||
return (await call_backend("on_steam_event", [data]))[0];
|
||||
}
|
||||
|
|
|
@ -73,11 +73,11 @@ const eval2 = eval;
|
|||
|
||||
function jsCallback() {
|
||||
return (script: backend.CJavascriptResponse) => {
|
||||
// register next callback (before running JS, in case that crashes)
|
||||
backend.resolve(backend.getJavascriptToRun(), jsCallback());
|
||||
if (script != null) {
|
||||
switch (script.result) {
|
||||
case "javascript":
|
||||
// register next callback (before running JS, in case that crashes)
|
||||
backend.resolve(backend.getJavascriptToRun(), jsCallback());
|
||||
let toRun = script as backend.CJavascriptResult;
|
||||
console.log("CAYLON: Got javascript " + toRun.id.toString(), toRun);
|
||||
let result = eval2(toRun.raw);
|
||||
|
@ -376,7 +376,6 @@ function buildAbout() {
|
|||
}
|
||||
|
||||
export default definePlugin((serverApi: ServerAPI) => {
|
||||
register_for_steam_events()
|
||||
return {
|
||||
title: <div className={staticClasses.Title}>{about == null? "Caylon": about.name}</div>,
|
||||
content: <Content serverAPI={serverApi} />,
|
||||
|
|
Reference in a new issue