Breaking websocket functionality out into its own module
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
use cli::parse_args;
|
||||
use websockets::{WebSocket, WebSocketError};
|
||||
use cli::{parse_args, Commands};
|
||||
|
||||
pub(crate) mod cli;
|
||||
pub(crate) mod websocket;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), WebSocketError> {
|
||||
parse_args();
|
||||
let mut ws = WebSocket::connect("ws://localhost:8080/").await?;
|
||||
async fn main() {
|
||||
let args = parse_args();
|
||||
|
||||
ws.send_text("foo".to_string()).await?;
|
||||
// ws.receive().await?;
|
||||
// ws.close(None).await?;
|
||||
loop {
|
||||
let msg = ws.receive().await?;
|
||||
println!("Received: {:?}", msg);
|
||||
match &args.command {
|
||||
Some(Commands::Init {}) => {
|
||||
println!("Initializing Side Node")
|
||||
}
|
||||
Some(Commands::Run {}) => {
|
||||
websocket::start().await.unwrap();
|
||||
}
|
||||
None => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user