Skip to content

Commit

Permalink
perf: global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhazhazhu committed Jan 26, 2024
1 parent 94ede0e commit a394359
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion crates/cli/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use std::{
};
use tokio::{sync::mpsc, task};

const HOME_URL: &str = "https://air.zhazhazhu.me";

#[derive(Clone)]
struct AppState {
file_path: PathBuf,
Expand All @@ -46,7 +48,7 @@ pub async fn run_server(cli: Cli) -> Result<(), std::io::Error> {
create_qrcode(&download_url).unwrap();

println!("");
println!("➤ Home: {}", "https://air.zhazhazhu.me".green());
println!("➤ Home: {}", HOME_URL.green());
println!("➤ Download: {}", download_url.green());
println!("");

Expand Down
4 changes: 3 additions & 1 deletion crates/cli/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use colored::Colorize;
use serde::{Deserialize, Serialize};
use websockets::{Frame, WebSocket};

const WS_HOST: &str = "ws://120.55.189.199:8080/ws";

#[derive(Deserialize, Serialize, Debug)]
pub struct Service {
pub ip: String,
Expand All @@ -10,7 +12,7 @@ pub struct Service {

pub async fn connect_and_handle_messages(service: Service) {
println!("Ws: server connecting...");
match WebSocket::connect("ws://120.55.189.199:8080/ws").await {
match WebSocket::connect(WS_HOST).await {
Ok(mut ws) => {
println!("{}", "Ws: server connect success".green());
let value = serde_json::to_string(&service).unwrap();
Expand Down

0 comments on commit a394359

Please sign in to comment.