Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
claustra01 committed Aug 10, 2024
1 parent bee5926 commit 9f8edf1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
12 changes: 8 additions & 4 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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 (
Expand Down
3 changes: 2 additions & 1 deletion src/pages/shooter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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));
Expand Down
39 changes: 23 additions & 16 deletions src/type/schema.ts
Original file line number Diff line number Diff line change
@@ -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",
}

0 comments on commit 9f8edf1

Please sign in to comment.