Backend/client.js
2021-12-31 15:03:23 +05:30

15 lines
314 B
JavaScript

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)
}