feat: 初始化项目结构并添加位置上报相关功能
This commit is contained in:
26
packages/gotify-ws/src/main.rs
Normal file
26
packages/gotify-ws/src/main.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
mod utils;
|
||||
|
||||
use futures::StreamExt;
|
||||
use log::info;
|
||||
use tokio_tungstenite::connect_async;
|
||||
use utils::logger;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
logger::init_logger();
|
||||
const WS: &str = "wss://home.hzer.xyz/gotify/stream?token=CDIwYlYJuxWxVr5";
|
||||
|
||||
match connect_async(WS).await {
|
||||
Ok((stream, _)) => {
|
||||
info!("Connected to Gotify server {WS}");
|
||||
|
||||
let (_, mut read) = stream.split();
|
||||
while let Some(msg) = read.next().await {
|
||||
info!("Received message: {msg:?}");
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
info!("Failed to connect to Gotify server: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
5
packages/gotify-ws/src/utils/logger/mod.rs
Normal file
5
packages/gotify-ws/src/utils/logger/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
use env_logger::{Builder, Env};
|
||||
|
||||
pub fn init_logger(){
|
||||
Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||
}
|
||||
1
packages/gotify-ws/src/utils/mod.rs
Normal file
1
packages/gotify-ws/src/utils/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod logger;
|
||||
Reference in New Issue
Block a user