diff --git a/src/commands.rs b/src/commands.rs index d1a2fe2..1c50256 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -5,7 +5,6 @@ use std::sync::mpsc::{self, Receiver, Sender}; use std::sync::{Arc, Mutex}; use std::thread; use ws::{listen, Message, Result as WsResult}; -use qrcode::{render::unicode::{self}, QrCode}; use crate::structs::{IntoMessage, LocationPayload}; @@ -122,9 +121,7 @@ pub fn stop() -> &'static str { "Stopping WebSocket server" } -pub fn local_qrcode() -> Vec { - let mut result = Vec::::new(); - +pub fn local_address() -> String { fn get_local_ip() -> Result { let socket = UdpSocket::bind("0.0.0.0:0").map_err(|e| e.to_string())?; socket @@ -136,24 +133,14 @@ pub fn local_qrcode() -> Vec { .map_err(|e| e.to_string()) } - fn draw_qrcode(data: String) -> String { - let code = QrCode::new(data).expect("Failed to generate QR Code"); - let ascii_qr = code.render::().quiet_zone(false).build(); - return ascii_qr.replace("\n", ",") - } - let parsed_data = get_local_ip(); match parsed_data { Ok(ip) => { - result.push(draw_qrcode(ip.to_string())); - result.push(ip.to_string()) + return format!("ws://{}:4152", ip.to_string()); }, Err(_) => { - result.push("not provided".to_string()); - result.push("not provided".to_string()); + return "not provided".to_string(); }, } - - return result; -} +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 7952f5b..15fda45 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ pub fn init() -> Extension { Extension::build() .command("start", commands::start) .command("stop", commands::stop) - .command("local_ip", commands::local_qrcode) + .command("local_ip", commands::local_address) .command("message", commands::message) .command("location", commands::location) .finish()