0.0.7 • Published 12 months ago

websocketwithheartbeat v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
12 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

12 months ago

0.0.6

12 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago