0.0.7 • Published 11 months ago

websocketwithheartbeat v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

webSocketWithHeartbeat

Description

webSocketWithHeartbeat is a simple project to demonstrate a WebSocket connection with a heartbeat mechanism.

Installation

npm install --save websocketwithheartbeat

Usage

import WebSocketWithHeartbeat from 'webSocketWithHeartbeat'

const socket = new WebSocketWithHeartbeat('https://example.com')
// if you need to create multiple instances, use getInstance()
const socket = WebSocketWithHeartbeat.getInstance('https://example.com')

socket.onopen = () => {
    console.log('WebSocket connection established')
}
socket.onmessage = (event: MessageEvent) => {
    const data = event.data
    console.log('WebSocket message received:', data)
}
socket.onclose = () => {
    console.log('WebSocket connection closed')
}
socket.onerror = (error: Event) => {
    console.error('WebSocket error:', error)
}
socket.send('Hello, WebSocket!')
0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago

0.0.0

12 months ago