···1+tiny program that listens on a port for *any* tcp connection (but assuming its http so curl / webhooks etc. work fine) and plays a click sound using [`quad-snd`](https://github.com/not-fl3/quad-snd).
2+3+the click sound is taken from https://github.com/enjarai/clickrtraining.
+24
UNLICENSE
···000000000000000000000000
···1+This is free and unencumbered software released into the public domain.
2+3+Anyone is free to copy, modify, publish, use, compile, sell, or
4+distribute this software, either in source code form or as a compiled
5+binary, for any purpose, commercial or non-commercial, and by any
6+means.
7+8+In jurisdictions that recognize copyright laws, the author or authors
9+of this software dedicate any and all copyright interest in the
10+software to the public domain. We make this dedication for the benefit
11+of the public at large and to the detriment of our heirs and
12+successors. We intend this dedication to be an overt act of
13+relinquishment in perpetuity of all present and future rights to this
14+software under copyright law.
15+16+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+OTHER DEALINGS IN THE SOFTWARE.
23+24+For more information, please refer to <https://unlicense.org/>
+35
src/main.rs
···00000000000000000000000000000000000
···1+use std::{
2+ io::{BufRead, BufReader, Write},
3+ net::TcpListener,
4+};
5+6+use quad_snd::*;
7+8+const CLICK: &[u8] = include_bytes!("./sound.ogg");
9+10+fn main() {
11+ let ctx = AudioContext::new();
12+ let click = Sound::load(&ctx, CLICK);
13+14+ let port = std::env::var("PORT")
15+ .ok()
16+ .and_then(|p| p.parse::<u16>().ok())
17+ .unwrap_or(8668);
18+ let listener = TcpListener::bind(("0.0.0.0", port)).expect("cant bind");
19+20+ for stream in listener.incoming() {
21+ let Ok(mut stream) = stream else {
22+ continue;
23+ };
24+ click.play(&ctx, PlaySoundParams::default());
25+ // exhaust connection to not get "connection reset by peer"
26+ BufReader::new(&stream)
27+ .lines()
28+ .flatten()
29+ .take_while(|line| !line.is_empty())
30+ .for_each(drop);
31+ // this never "fails"
32+ let response = "HTTP/1.1 200 OK\r\n\r\n";
33+ let _ = stream.write_all(response.as_bytes());
34+ }
35+}