Realtime Cloud Messaging JavaScript SDK
JavaScript
Latest commit e98a028 Jan 17, 2017 @jparreira jparreira Fixes #5
Permalink
Failed to load latest commit information.
dist Fixes #5 Jan 17, 2017
.gitignore Updated gitignore Jan 9, 2017
LICENSE Initial commit Aug 17, 2016
README.md Updated TypeScript definitions Jan 10, 2017
bower.json Fixes #5 Jan 17, 2017
ortc.js Fixes #5 Jan 17, 2017
ortc.umd.d.ts Updated TypeScript definitions Jan 10, 2017
ortc.umd.js Fixes #5 Jan 17, 2017
package.json Fixes #5 Jan 17, 2017
webpack.config.js added umd version of library Oct 1, 2016

README.md

Realtime Cloud Messaging JavaScript SDK

Part of the The Realtime® Framework, Realtime Cloud Messaging (aka ORTC) is a secure, fast and highly scalable cloud-hosted Pub/Sub real-time message broker for web and mobile apps.

If your application has data that needs to be updated in the user’s interface as it changes (e.g. real-time stock quotes or ever changing social news feed) Realtime Cloud Messaging is the reliable, easy, unbelievably fast, “works everywhere” solution.

We have included the source code and licence for the sockjs-client library.

Installation

If you're using Realtime on a web page, you can install the library via:

CDN

<script src="//messaging-public.realtime.co/js/2.1.0/ortc.js"></script>

Usage:

var client = RealtimeMessaging.createClient();
client.setClusterUrl("http://ortc-developers.realtime.co/server/2.1/");
client.connect('YOUR_APPKEY', 'token');

client.onConnected = function(client) {
    console.log("realtime connected");
    client.subscribe("channel", true, function(client, channel, message) {
        console.log("Received message:", message);
    });
}

Bower

bower install realtime

and then

<script src="bower_components/realtime/dist/ortc-min.js"></script>

More about Bower at http://bower.io/

NPM

npm install realtime-messaging --save

and then

import * as RealtimeMessaging from 'realtime-messaging';

const client = RealtimeMessaging.createClient();
client.setClusterUrl("http://ortc-developers.realtime.co/server/2.1/");
client.connect('YOUR_APPKEY', 'token');

client.onConnected = (client) => {
    console.log("realtime connected");
    client.subscribe("channel", true, (client, channel, message) => {
        console.log("Received message:", message);
    });
}

TypeScript usage

import * as Realtime from 'realtime-messaging';

const realtime = Realtime.createClient();
realtime.setClusterUrl("https://ortc-developers.realtime.co/server/ssl/2.1/");
realtime.connect("YOUR_APPKEY", "SomeSecurityToken");

realtime.onConnected = onConnected;
realtime.onException = onException;

// Realtime connection is established
onConnected(client: Realtime.Client) {
    // subscribe a channel to receive messages
    client.subscribe("myChannel", true, onMessage);
}

// A new message was received
onMessage(client: Realtime.Client, channel: string, message: string) {
    console.log("Received message:", message);
}

Quick Start Guide

http://messaging-public.realtime.co/documentation/starting-guide/quickstart-js.html

API Reference

http://messaging-public.realtime.co/documentation/javascript/2.1.0/OrtcClient.html

Authors

Realtime.co