<template>
	<div>
		{{ id }}
	</div>
</template>

<script>
import { nanoid } from 'nanoid'
import { ref } from '@nuxtjs/composition-api'
import { tryOnMounted, useLocalStorage } from '@vueuse/core'
import connectWebsocket from '~/composables/connectWebsocket'

export default {
	name: 'IndexPage',
	setup() {
		const { data, send, open } = connectWebsocket()
		const id = ref(null)

		tryOnMounted(() => {
			open()
			id.value = useLocalStorage('ooc_user_id', nanoid())
		})

		return {
			send,
			data,
			open,
			id,
		}
	},
}
</script>
