libserpix_rs

Crates.iolibserpix_rs
lib.rslibserpix_rs
version0.5.3
sourcesrc
created_at2023-06-06 00:44:14.954184
updated_at2023-06-14 01:02:57.251335
descriptionReal-time data transmission out of World of Warcraft via encoding data into pixels
homepagehttps://github.com/alex-berliner/libserpix_rs
repositoryhttps://github.com/alex-berliner/libserpix_rs
max_upload_size
id883447
size43,679
Alex Berliner (alex-berliner)

documentation

README

libserpix_rs

This is a Rust library acting as the screen reader portion to accompany the lua library LibSerpix, which allows real-time data transmission out of World of Warcraft via encoding data into pixels. Together they allow one to transmit JSON formatted messages out of World of Warcraft in real time.

Example

This is src/bin/wow.rs. Run with cargo run --release --bin wow.

use std::time::Instant;
use tokio::sync::mpsc::{channel, error};
use libserpix_rs::*;

#[tokio::main]
async fn main() {
    let (tx, mut rx) = channel(100);
    let mut handles = vec![];
    // Thread #1: scan WoW window
    let h = tokio::spawn(async move {
        let hwnd = win_screenshot::utils::find_window("World of Warcraft").expect("Couldn't find window");
        loop {
            read_wow(hwnd, tx.clone()).await;
        }
    });
    handles.push(h);
    // Thread #2: parse output
    let h = tokio::spawn(async move {
        loop {
            match rx.try_recv() {
                Ok(v) => {
                    let jstring = &v.to_string();
                    println!("{}",jstring);
                },
                Err(e) => {
                    match e {
                        error::TryRecvError::Disconnected => break,
                        _ => {}
                    }
                }
            }
        }
    });
    handles.push(h);
    for handle in handles {
        handle.await.expect("Thread exited");
    }
}
Commit count: 100

cargo fmt