Skip to content

Commit

Permalink
chore(deps): viz 0.8.0 (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon authored Jan 13, 2024
1 parent 5c9c00d commit d890ba4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/viz-echo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version.workspace = true
edition.workspace = true

[dependencies]
viz = ">=0.7.1"
viz = "0.8.0"
socketioxide = { path = "../../socketioxide" }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
tracing-subscriber.workspace = true
Expand Down
14 changes: 6 additions & 8 deletions examples/viz-echo/viz_echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use socketioxide::{
extract::{AckSender, Bin, Data, SocketRef},
SocketIo,
};
use std::sync::Arc;
use tracing::info;
use tracing::{error, info};
use tracing_subscriber::FmtSubscriber;
use viz::{handler::ServiceHandler, serve_with_upgrades, Result, Router, Tree};
use viz::{handler::ServiceHandler, serve, Result, Router};

fn on_connect(socket: SocketRef, Data(data): Data<Value>) {
info!("Socket.IO connected: {:?} {:?}", socket.ns(), socket.id);
Expand Down Expand Up @@ -41,15 +40,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = Router::new()
.get("/", |_| async { Ok("Hello, World!") })
.any("/*", ServiceHandler::new(svc));
let tree = Arc::new(Tree::from(app));

info!("Starting server");

let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();

loop {
let (stream, addr) = listener.accept().await?;
let tree = tree.clone();
tokio::task::spawn(serve_with_upgrades(stream, tree, Some(addr)));
if let Err(e) = serve(listener, app).await {
error!("{}", e);
}

Ok(())
}

0 comments on commit d890ba4

Please sign in to comment.