Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WebsocketServer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let (layer, io) = SocketIo::builder().with_state(db_client).build_layer();

io.ns("/", |s: SocketRef, Data::<MyAuthData>(auth)| async move { // Data::<MyAuthData>(auth)
io.ns("/", |s: SocketRef, Data::<MyAuthData>(auth)| async move {
// ----- Test event ----- //
// s.on("client to server event", |s: SocketRef| {
// let _ = s.emit("server to client event", "Received client to server event");
Expand Down
28 changes: 17 additions & 11 deletions WssDedicated/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use axum::{http::Method, routing::get};
use serde::{Deserialize, Serialize};
use axum::routing::get;

use serde::{
Deserialize,
Serialize
};

use serde_json::Value;

use socketioxide::{
extract::{
AckSender,
Expand All @@ -9,11 +15,17 @@ use socketioxide::{
},
SocketIo,
};

use dotenv::dotenv;
use std::{env, net::SocketAddr};

use std::{
env,
net::SocketAddr
};

use tower::ServiceBuilder;
use tower_http::cors::{Any, CorsLayer};
use http::header::CONTENT_TYPE;

use tower_http::cors::CorsLayer;

#[derive(Debug, Deserialize, Serialize, Clone)]
struct ClientPayload {
Expand Down Expand Up @@ -73,12 +85,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// authenticate_clients(s, auth).await; // Authenticate the client with their "auth.token"
});

let cors = CorsLayer::new()
// .allow_methods([Method::GET, Method::POST])
// .allow_origin(Any)
.allow_headers(Any)
;

let app = axum::Router::new()
.with_state(io)
.route("/test", get(|| async move { println!("Test Route"); "Test Route" } ))
Expand Down