Giter Site home page Giter Site logo

realtimemessaging-javascript's Introduction

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 in Angular4

import {Component, OnInit} from '@angular/core';
import * as Realtime from 'realtime-messaging';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

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

    realtime.onConnected = (client: Realtime.Client) => {
      console.log("connected");
      
      // subscribe a channel to receive message
      client.subscribe("myChannel", true, this.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

realtimemessaging-javascript's People

Contributors

jparreira avatar realtime-framework avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

realtimemessaging-javascript's Issues

ionic2 fails ugliyfy-js due to ` in ortc.umd.js

integrating ortc into a new ionic2 app and was unable to build for android (works on ionic serve) due to the `` inside delegateExceptionCallback for setHeartbeat* methods starting at line 183 please update / advise I have made a local work around but this will affect others in the future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.