ChannelStream JS Client

Usage no npm install needed!

<script type="module">
  import channelstreamChannelstream from 'https://cdn.skypack.dev/@channelstream/channelstream';



Browser client for Channelstream websocket server.



First run channelstream server:


Now you can implement the client side of websocket handling, first install the client:

npm i @channelstream/channelstream  

You are ready to add the client to your application and act on events:

import {ChannelStreamConnection} from '@channelstream/channelstream';
let connection = new ChannelStreamConnection();
// this points to your application view
connection.connectUrl = '/connect';
connection.messageUrl = '/message';
// this points to channelstream
connection.websocketUrl = 'ws://';
connection.longPollUrl = '';

connection.listenMessageCallback = (messages) => {
    for (let message of messages) {
        console.log('channelstream message', message);
        // Do something on message received
// optional
connection.listenOpenedCallback = () => {
    // Do something on websocket open
// this will try to obtain connection UUID from `connectUrl` endpoint of your 
// WEB application via XHR calland then use it to make websocket connection

// optionally set the username for XHR call
// your server side application can normally handle this
connection.username = "someID"


Consult the project website for more in depth examples.


BSD 3-Clause License