Get started with deepstream.io-client-js CDN

Apache-2.0 licensed

Deepstream.io-client-js is a library for real-time communication with Deepstream.io platform.

Tags:
  • deepstream
  • realtime
  • server
  • datasync
  • pubsub
  • rpc
  • streaming

Stable version

Copied!

How to start using deepstream.io-client-js CDN


// Include Deepstream.io client library from CDN
const Deepstream = require('deepstream.io-client-js');

// Initialize the Deepstream client with the server URL
const client = new Deepstream.Client('wss://your-deepstream-server-url:4433/');

// Connect to the server
client.on('connect', () => {
  console.log('Connected to Deepstream server.');

  // Create a new text message channel
  const textChannel = client.record('textMessages');

  // Subscribe to the text message channel
  textChannel.on('deepstream.event:subscribe', () => {
    console.log('Subscribed to text message channel.');

    // Listen for incoming messages
    textChannel.on('new_message', (message) => {
      console.log(`Received message: ${message}`);
    });
  });

  // Send a test message to the text message channel
  textChannel.emit('send_message', 'Hello, Deepstream!');
});

// Handle errors
client.on('error', (error) => {
  console.error('Error:', error);
});

// Connect to the Deepstream server
client.connect();
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions