https://github.com/jeankassio/async-client-websocket
Async Client Websocket is an asynchronous Websocket Client built with the aim of making your connection lighter and more functional.
https://github.com/jeankassio/async-client-websocket
async async-websocket-client async-websockets websocket websocket-client websockets websockets-client
Last synced: about 2 months ago
JSON representation
Async Client Websocket is an asynchronous Websocket Client built with the aim of making your connection lighter and more functional.
- Host: GitHub
- URL: https://github.com/jeankassio/async-client-websocket
- Owner: jeankassio
- License: mit
- Created: 2023-05-24T12:21:47.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-14T08:23:05.000Z (11 months ago)
- Last Synced: 2025-12-28T17:52:00.434Z (6 months ago)
- Topics: async, async-websocket-client, async-websockets, websocket, websocket-client, websockets, websockets-client
- Language: JavaScript
- Homepage: https://jeankassio.dev
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Async Client Websocket
Async Client Websocket is an asynchronous Websocket Client built with the aim of making your connection lighter and more functional.
## Access file
Import the AsyncClientWebSocket.js file to your server, or use the CDN:
https://cdn.jsdelivr.net/gh/jeankassio/Async-Client-Websocket@main/src/AsyncClientWebSocket.min.js
## How to use
```javascript
const Server = new WebSocketClient('wss://your_wss.com');
//Methods:
Server.connect(timeout = 5000);
Server.send(message);
Server.disconnect();
Server.destroy();
Server.isConnected();
Server.saveQueueOnLocalStorage(status);
Server.startKeepAlive(interval = 15000, ping); //"ping" is the word that your server will receive as a ping if you use a word other than "ping"
Server.stopKeepAlive();
Server.trackLatency(interval = 10000, ping, pong); //"ping" and "pong" is the word that your server will receive as a ping if you use a word other than "ping"/"pong"
Server.untrackLatency();
Server.getLatency();
Server.autoReconnect(interval = 3000, maxAttemps = infinity, callback = null);
Server.preventSpam(interval = 100); //"interval" is the minimum time allowed between one message and another message
Server.allowSpam();
Server.log(status = true);
Server.setOutgoingMiddleware(fn);
Server.setIncomingMiddleware(fn);
//Events
Server.onOpen = (event) => {
};
Server.onClose = (event) => {
};
Server.onMessage = (message) => {
};
Server.onError = (error) => {
};
Server.onSpam = (message) => {
};
Server.onVerbose = (verboseMessage) => {
};
Server.onLatency = (latency) => {
};
function wsSend(message) {
Server.send(message);
}
function wsClose() {
Server.disconnect();
}
async function wsConnect(){
await Server.connect();
}
```