Get started with iris-ws CDN

BSD-3-Clause licensed

Iris-WS is a lightweight library for building RESTful web services using Node.js and Express.

Tags:
  • iris
  • golang
  • websocket
  • iris-golang
  • rich-websocket-server
  • cross-platform

Stable version

Copied!

How to start using iris-ws CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with iris-ws CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/iris-ws/12.2.10/client.min.js"></script>
</head>
<body>
    <button id="connect">Connect</button>
    <div id="messages"></div>

    <script>
        const socket = new Iris.Socket('wss://your-websocket-server.com');
        const connectButton = document.getElementById('connect');
        const messagesDiv = document.getElementById('messages');

        connectButton.addEventListener('click', () => {
            socket.connect();

            socket.on('open', () => {
                connectButton.textContent = 'Disconnect';
                console.log('Connected to WebSocket server.');

                socket.send('Hello, WebSocket!');

                socket.on('message', (message) => {
                    const messageElement = document.createElement('p');
                    messageElement.textContent = message;
                    messagesDiv.appendChild(messageElement);
                });
            });

            socket.on('close', () => {
                connectButton.textContent = 'Connect';
                console.log('Disconnected from WebSocket server.');
            });
        });
    </script>
</body>
</html>

All versions