Closed yasuto2002 closed 1 year ago
https://github.com/theturtle32/WebSocket-Node
<script lang="ts" setup>
import * as WebSocket from "websocket";
const socket = new WebSocket.w3cwebsocket("ws://localhost:80/ws");
</script>
__vite_ssr_import_1__.w3cwebsocket is not a constructor
が出る
<script setup>
onMounted( () => { const config = useRuntimeConfig() const ws = new WebSocket(config.socket) ws.onopen = function () { console.log("接続が開かれたときに呼び出されるイベント"); }; ws.onmessage = function (event) { console.log(event.data) }; function send() { let send_msg = "aaaa" ws.send(send_msg); } })
## 接続自体は可能に
<img width="1353" alt="スクリーンショット 2022-12-09 10 31 31" src="https://user-images.githubusercontent.com/77332271/206602621-22600e50-ee29-4025-848f-6024d975d8b9.png">
やりたいこと