Skip to content

Commit 2f3167f

Browse files
committed
chore: use /ws/visitors
1 parent 4314690 commit 2f3167f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Inspired by <a href="https://github.com/cloudflare/templates/tree/main/multiplay
2525

2626
When the first request is made, the server store the user's location (latitude and longitude) using the [`useState`](https://nuxt.com/docs/api/composables/use-state) composable in the [`app/plugins/location.server.ts`](./app/plugins/location.server.ts) file.
2727

28-
A `/visitors` websocket endpoint is created in the [`server/routes/visitors.ts`](./server/routes/visitors.ts) file using the [`defineWebSocketHandler`](https://nitro.build/guide/websocket) function.
28+
A `/ws/visitors` websocket endpoint is created in the [`server/routes/ws/visitors.ts`](./server/routes/ws/visitors.ts) file using the [`defineWebSocketHandler`](https://nitro.build/guide/websocket) function.
2929

30-
When the [`index.vue` page](./app/pages/index.vue) is mounted on client-side, it connects to the `/visitors` websocket endpoint with its location as query parameters to the server.
30+
When the [`index.vue` page](./app/pages/index.vue) is mounted on client-side, it connects to the `/ws/visitors` websocket endpoint with its location as query parameters to the server.
3131

3232
The websocket endpoints send back the user locations to the client-side.
3333

app/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const phi = ref(0)
77
const locations = ref<Array<{ latitude: number, longitude: number }>>([])
88
99
// Connect to the websocket endpoint
10-
const { data, open } = useWebSocket(`/visitors?latitude=${myLocation.value.latitude}&longitude=${myLocation.value.longitude}`, { immediate: false })
10+
const { data, open } = useWebSocket(`/ws/visitors?latitude=${myLocation.value.latitude}&longitude=${myLocation.value.longitude}`, { immediate: false })
1111
// When the data is received, we parse it as JSON and update the locations
1212
watch(data, async (newData) => {
1313
locations.value = JSON.parse(typeof newData === 'string' ? newData : await newData.text())
File renamed without changes.

0 commit comments

Comments
 (0)