https://github.com/realtime-framework/realtimemessaging-javascript
Realtime Cloud Messaging JavaScript SDK
https://github.com/realtime-framework/realtimemessaging-javascript
realtime-messaging typescript-library umd-modules websockets
Last synced: 10 months ago
JSON representation
Realtime Cloud Messaging JavaScript SDK
- Host: GitHub
- URL: https://github.com/realtime-framework/realtimemessaging-javascript
- Owner: realtime-framework
- License: mit
- Created: 2016-08-17T11:24:30.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-06-21T12:08:04.000Z (almost 9 years ago)
- Last Synced: 2025-07-04T09:07:53.802Z (11 months ago)
- Topics: realtime-messaging, typescript-library, umd-modules, websockets
- Language: JavaScript
- Size: 351 KB
- Stars: 4
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Realtime Cloud Messaging JavaScript SDK
Part of the [The Realtime® Framework](http://framework.realtime.co), 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
```html
```
Usage:
```javascript
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
```bash
bower install realtime
```
and then
```html
```
More about Bower at [http://bower.io/](http://bower.io/)
#### NPM
```bash
npm install realtime-messaging --save
```
and then
```javascript
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
```typescript
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](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](http://messaging-public.realtime.co/documentation/javascript/2.1.0/OrtcClient.html)
## Authors
Realtime.co