Backend/client.js

15 lines
314 B
JavaScript
Raw Normal View History

2021-12-31 09:33:23 +00:00
const WebSocket = require('ws')
const url = 'ws://localhost:9000'
const connection = new WebSocket(url)
connection.onopen = () => {
connection.send("Message From Client")
}
connection.onerror = (error) => {
console.log("WebSocket error:", error)
}
connection.onmessage = (e) => {
console.log(e.data)
}