play indoor chime on ring
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -83,9 +83,15 @@ async fn main() {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
sse::reply(stream)
|
sse::reply(stream)
|
||||||
});
|
});
|
||||||
|
|
||||||
let routes = root.or(events);
|
// GET /*
|
||||||
|
let statics = warp::get()
|
||||||
|
.and(warp::path::peek())
|
||||||
|
.map(|path| info!("GET /* : {:?}", path)).untuple_one()
|
||||||
|
.and(warp::fs::dir("static"));
|
||||||
|
|
||||||
|
let routes = root.or(events).or(statics);
|
||||||
warp::serve(routes).run(([0, 0, 0, 0], 8060)).await;
|
warp::serve(routes).run(([0, 0, 0, 0], 8060)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
<section id="log">
|
<section id="log">
|
||||||
<h1>Incoming Events</h1>
|
<h1>Incoming Events</h1>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<audio id="chime" src="indoor.mp3"></audio>
|
||||||
<template id="connected">
|
<template id="connected">
|
||||||
<span class="connected">Connected</span>
|
<span class="connected">Connected</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -60,6 +62,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
sse.addEventListener('ring', msg => {
|
sse.addEventListener('ring', msg => {
|
||||||
|
let chime = document.getElementById('chime');
|
||||||
|
if (chime.paused) {
|
||||||
|
chime.play();
|
||||||
|
}
|
||||||
const template = get_template('ring');
|
const template = get_template('ring');
|
||||||
$('#log').append(template);
|
$('#log').append(template);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user