Get started with sockjs-client CDN
MIT licensed
SockJS-client: library for real-time, bi-directional communication using SockJS protocol.
Tags:- websockets
- node
Stable version
Copied!
How to start using sockjs-client CDN
// Include SockJS library from the CDN
const SockJS = (() => {
const script = document.createElement('script');
script.src = 'https://cdn.cdnhub.io/sockjs-client/1.6.1/sockjs.min.js';
document.head.appendChild(script);
return new Promise((resolve) => {
script.onload = () => {
document.head.removeChild(script);
resolve(SockJS);
};
});
})();
// Create a new SockJS connection
const socket = new SockJS('http://your-server.com/your-endpoint');
// Connect to the server
socket.onopen = () => {
console.log('Connected to server');
};
// Listen for messages from the server
socket.onmessage = (event) => {
console.log('Received message:', event.data);
};
// Send a message to the server
socket.send('Hello, server!');
Copied!
Copied!
Copied!
Copied!
All versions
0.2.1
0.3.2
0.3.4
1.0.0
1.0.0-beta.1
1.0.0-beta.10
1.0.0-beta.11
1.0.0-beta.12
1.0.0-beta.13
1.0.0-beta.2
1.0.0-beta.3
1.0.0-beta.4
1.0.0-beta.5
1.0.0-beta.6
1.0.0-beta.7
1.0.0-beta.8
1.0.0-beta.9
1.0.1
1.0.2
1.0.3
1.1.0
1.1.1
1.1.2
1.1.3
1.1.4
1.1.5
1.2.0
1.3.0
1.4.0
1.5.0
1.5.1
1.5.2
1.6.0
*** 1.6.1