mirror of
https://github.com/thilo-behnke/wasm-pong.git
synced 2026-07-12 11:09:38 +00:00
fix session join
This commit is contained in:
@@ -63,14 +63,14 @@ const sessionEvents = (session: Session) => readable([], function(set) {
|
||||
set(get(events));
|
||||
}, 0)
|
||||
|
||||
set(get(events));
|
||||
set([]);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
}
|
||||
})
|
||||
|
||||
const inputEvents = (session: Session): Readable<unknown[]> => derived(sessionEvents(session), ([$sessionEvents]) => $sessionEvents.filter(({input}) => input === 'topic'));
|
||||
const inputEvents = (session: Session): Readable<unknown[]> => derived(sessionEvents(session), $sessionEvents => $sessionEvents.filter(({input}) => input === 'topic'));
|
||||
|
||||
export const sessionInputs = (session: Session) => readable([], function(setInputs) {
|
||||
let player1Inputs = writable([]);
|
||||
|
||||
@@ -91,7 +91,7 @@ async fn handle_potential_ws_upgrade(session_manager: Arc<Mutex<SessionManager>>
|
||||
return res;
|
||||
}
|
||||
let session_id = params.get("session_id").unwrap();
|
||||
let request_player_id = addr.to_string();
|
||||
let request_player_id = addr.ip().to_string();
|
||||
let session = session_manager.lock().await.get_session(session_id);
|
||||
if let None = session {
|
||||
let error = format!("Session does not exist: {}", session_id);
|
||||
|
||||
@@ -72,7 +72,7 @@ async fn handle_session_create(
|
||||
println!("Called to create new session: {:?}", req);
|
||||
let mut locked = session_manager.lock().await;
|
||||
let player = Player {
|
||||
id: addr.to_string(),
|
||||
id: addr.ip().to_string(),
|
||||
};
|
||||
let session_create_res = locked.create_session(player.clone()).await;
|
||||
if let Err(e) = session_create_res {
|
||||
@@ -100,7 +100,7 @@ async fn handle_session_join(
|
||||
let mut locked = session_manager.lock().await;
|
||||
let body = read_json_body::<SessionJoinDto>(&mut req).await;
|
||||
let player = Player {
|
||||
id: addr.to_string(),
|
||||
id: addr.ip().to_string()
|
||||
};
|
||||
let session_join_res = locked.join_session(body.session_id, player.clone()).await;
|
||||
if let Err(e) = session_join_res {
|
||||
|
||||
Reference in New Issue
Block a user