Spaces:
Runtime error
Runtime error
Fixed touch
Browse files
server/src/socket/hapticLinkServer.ts
CHANGED
|
@@ -110,7 +110,11 @@ export class HapticLinkServer {
|
|
| 110 |
user,
|
| 111 |
};
|
| 112 |
|
| 113 |
-
if (route
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
route.handler(context);
|
| 115 |
} else {
|
| 116 |
return ws.send(JSON.stringify({ error: "invalid payload format" }));
|
|
|
|
| 110 |
user,
|
| 111 |
};
|
| 112 |
|
| 113 |
+
if (!route) {
|
| 114 |
+
return ws.send(JSON.stringify({ error: "invalid route" }));
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
if (route.schema.safeParse(payload).success) {
|
| 118 |
route.handler(context);
|
| 119 |
} else {
|
| 120 |
return ws.send(JSON.stringify({ error: "invalid payload format" }));
|
server/src/socket/routes.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import { HapticLinkServer } from "./hapticLinkServer";
|
| 2 |
import { JoinRoomHandler, JoinRoomSchema } from "./routes/join_room";
|
| 3 |
import { LeaveRoomHandler, LeaveRoomSchema } from "./routes/leave_room";
|
|
|
|
| 4 |
import { SetUsernameHandler, SetUsernameSchema } from "./routes/set_username";
|
| 5 |
import { TestConnnectionSchema, TestConnectionHandler } from "./routes/test_connection";
|
| 6 |
|
|
@@ -8,6 +9,6 @@ export function registerRoutes(router: HapticLinkServer) {
|
|
| 8 |
router.addRoute("test_connection", TestConnnectionSchema, TestConnectionHandler);
|
| 9 |
router.addRoute("join_room", JoinRoomSchema, JoinRoomHandler);
|
| 10 |
router.addRoute("leave_room", LeaveRoomSchema, LeaveRoomHandler);
|
| 11 |
-
router.addRoute("send_touch",
|
| 12 |
router.addRoute("set_username", SetUsernameSchema, SetUsernameHandler);
|
| 13 |
}
|
|
|
|
| 1 |
import { HapticLinkServer } from "./hapticLinkServer";
|
| 2 |
import { JoinRoomHandler, JoinRoomSchema } from "./routes/join_room";
|
| 3 |
import { LeaveRoomHandler, LeaveRoomSchema } from "./routes/leave_room";
|
| 4 |
+
import { SendVibrationHandler, SendVibrationSchema } from "./routes/send_vibration";
|
| 5 |
import { SetUsernameHandler, SetUsernameSchema } from "./routes/set_username";
|
| 6 |
import { TestConnnectionSchema, TestConnectionHandler } from "./routes/test_connection";
|
| 7 |
|
|
|
|
| 9 |
router.addRoute("test_connection", TestConnnectionSchema, TestConnectionHandler);
|
| 10 |
router.addRoute("join_room", JoinRoomSchema, JoinRoomHandler);
|
| 11 |
router.addRoute("leave_room", LeaveRoomSchema, LeaveRoomHandler);
|
| 12 |
+
router.addRoute("send_touch", SendVibrationSchema, SendVibrationHandler);
|
| 13 |
router.addRoute("set_username", SetUsernameSchema, SetUsernameHandler);
|
| 14 |
}
|