readme
parent
9d582d3bf4
commit
d2e4a4de28
|
|
@ -10,3 +10,10 @@ Stateless `X <-> Y` formatting+conversion in Rust
|
||||||
* [todo] kafka
|
* [todo] kafka
|
||||||
|
|
||||||
+ a gui for live remapping STDIN to gamepad-ish buttons
|
+ a gui for live remapping STDIN to gamepad-ish buttons
|
||||||
|
|
||||||
|
## StdIn to UDP
|
||||||
|
|
||||||
|
```
|
||||||
|
$ INPUT_NAME=stdin OUTPUT_NAME=udp OUTPUT_FORMAT="{{ ms_since_epoch }}|$USER|{{ VALUE }}" cargo run
|
||||||
|
$ INPUT_NAME=udp cargo run
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ pub struct InputStreamUDP {
|
||||||
|
|
||||||
pub fn build_input_stream_udp(cfg: &Stream) -> Result<InputStreamUDP, String> {
|
pub fn build_input_stream_udp(cfg: &Stream) -> Result<InputStreamUDP, String> {
|
||||||
let udp_cfg = cfg.engine.udp.as_ref().unwrap();
|
let udp_cfg = cfg.engine.udp.as_ref().unwrap();
|
||||||
|
println!("$ echo -n 'hello world' | nc -4u -w0 localhost {}", &udp_cfg.port.to_string());
|
||||||
return Ok(InputStreamUDP{
|
return Ok(InputStreamUDP{
|
||||||
last_socket: None,
|
last_socket: None,
|
||||||
port: udp_cfg.port,
|
port: udp_cfg.port,
|
||||||
|
|
@ -125,7 +126,6 @@ pub fn build_input_stream_udp(cfg: &Stream) -> Result<InputStreamUDP, String> {
|
||||||
impl InputStream for InputStreamUDP {
|
impl InputStream for InputStreamUDP {
|
||||||
fn get(&mut self) -> Vec<char> {
|
fn get(&mut self) -> Vec<char> {
|
||||||
let addr = "0.0.0.0:".to_string() + &self.port.to_string();
|
let addr = "0.0.0.0:".to_string() + &self.port.to_string();
|
||||||
println!("$ echo -n 'hello world' | nc -4u -w0 localhost {}", &self.port.to_string());
|
|
||||||
if self.last_socket.is_none() {
|
if self.last_socket.is_none() {
|
||||||
self.last_socket = Some(std::net::UdpSocket::bind(&addr).unwrap());
|
self.last_socket = Some(std::net::UdpSocket::bind(&addr).unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue