diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index 4e4bc5e..fd16bb2 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -4,8 +4,11 @@ import { useSocketRefStore } from "../../store"; import { device } from "../../utils/device"; import { requestPermission } from "../../utils/permission"; import styles from "./index.module.css"; +import { useNavigate } from "react-router-dom"; function Home() { + const navigate = useNavigate(); + const [isPcScreen, setIsPcScreen] = useState( window.matchMedia(device.pc).matches, ); @@ -32,19 +35,20 @@ function Home() { .play() .then(() => { setTimeout(() => { - window.location.href = isPcScreen ? "/yatai" : "/shooter"; + isPcScreen ? navigate("/yatai") : navigate("/shooter"); }, 500); }) .catch((error) => { console.error("オーディオの音が出なかった", error); - window.location.href = isPcScreen ? "/yatai" : "/shooter"; + isPcScreen ? navigate("/yatai") : navigate("/shooter"); }); requestPermission(); + console.log(import.meta.env.VITE_HOST_NAME); const socketRef = new WebSocket( - `wss://${import.meta.env.VITE_HOST_NAME}/ws`, + `ws://${import.meta.env.VITE_HOST_NAME}/ws?room_id=1`, ); setRef({ current: socketRef }); - window.location.href = isPcScreen ? "/yatai" : "/shooter"; + isPcScreen ? navigate("/yatai") : navigate("/shooter"); }; return ( diff --git a/src/pages/shooter/index.tsx b/src/pages/shooter/index.tsx index 6e482e7..cfba797 100644 --- a/src/pages/shooter/index.tsx +++ b/src/pages/shooter/index.tsx @@ -4,7 +4,7 @@ import { Modal } from "../../components/ui/Modal"; import { ShooterButton } from "../../components/ui/ShooterButton"; import { useOrientation } from "../../hooks/useOrientation"; import { useSocketRefStore, useUUIDStore } from "../../store"; -import { type Schema, message_type } from "../../type/schema"; +import { type Schema, event_type, message_type } from "../../type/schema"; import style from "./index.module.css"; const Shooter = () => { @@ -47,6 +47,7 @@ const Shooter = () => { z: 0, }, message_type: message_type.action, + event_type: event_type.shooter, }; socketRef?.current?.send(JSON.stringify(data)); setImages((prevImages) => prevImages.slice(1)); diff --git a/src/type/schema.ts b/src/type/schema.ts index b2ca2f0..52fcd9d 100644 --- a/src/type/schema.ts +++ b/src/type/schema.ts @@ -1,30 +1,37 @@ export interface Schema { - id: string; - interval: number; - angle: angle; - acceleration: acceleration; - distance: distance; - message_type: message_type; + id: string; + interval: number; + angle: angle; + acceleration: acceleration; + distance: distance; + message_type: message_type; + event_type: event_type; } interface angle { - x: number; - y: number; + x: number; + y: number; } interface acceleration { - x: number; - y: number; - z: number; + x: number; + y: number; + z: number; } interface distance { - x: number; - y: number; - z: number; + x: number; + y: number; + z: number; } export enum message_type { - pointer = "pointer", - action = "action", + pointer = "pointer", + action = "action", } + +export enum event_type { + shooter = "shooter", + ringToss = "ring_toss", + fireFlower = "fire_flower", +} \ No newline at end of file