Satori Docs

Your definitive guide to subscribing and publishing live data

JavaScript SDK Direct link

Satori provides the JavaScript SDK on the Satori CDN. Just include the SDK in your source file and create a client instance to begin publishing and subscribing. For Node.js, you can include it from the CDN or install it from Node Package Manager (npm).

The JavaScript SDK source is available in our public GitHub repository. See the README for more information.

CDN

To set up the JavaScript SDK from the CDN, include it in your source file.

https://satori-a.akamaihd.net/satori-rtm-sdk/v1.1.0/sdk.js (full)
// OR
https://satori-a.akamaihd.net/satori-rtm-sdk/v1.1.0/sdk.min.js (minified)

To test the SDK for a browser-based application, add the following file content to an HTML file in a text editor, replace ENDPOINT and APPKEY with your values from the General tab for the project in the Dev Portal, and open it in your browser:

<!DOCTYPE html>
<html>
  <head><title>JavaScript SDK - RTM Test</title></head>
  <body>
    <script src="https://satori-a.akamaihd.net/satori-rtm-sdk/v1.1.0/sdk.min.js"></script>
    <script>
      var endpoint = 'YOUR_ENDPOINT';
      var appkey = 'YOUR_APPKEY';

      var client = new RTM(endpoint, appkey);

      client.on('enter-connected', function () {
        console.log('Connected to Satori RTM!');
      });

      client.on('error', function (error) {
        console.log('Failed to connect', error);
      });

      client.start();
    </script>
  </body>
</html>

NPM (Node Package Manager)

To install the JavaScript SDK on Node.js, run the following command:

npm install satori-rtm-sdk

To test the SDK for Node.js, create the following JavaScript file named server.js, replace ENDPOINT and APPKEY with your values from the General tab for the project in the Dev Portal:

var RTM = require('satori-rtm-sdk');

var endpoint = 'YOUR_ENDPOINT';
var appkey = 'YOUR_APPKEY';

var client = new RTM(endpoint, appkey);

client.on('enter-connected', function () {
  console.log('Connected to Satori RTM!');
});

client.on('error', function (error) {
  console.log('Failed to connect', error);
});

client.start();

Run it with the following command:

node server.js

Java SDK Direct link

Satori provides the Java SDK through the Central Maven repository. The source is available in our public GitHub repository. See the README for more information.

Installing with Maven

Before you begin, make sure that you have Maven installed. For more information, see Install Maven.

To install the Java SDK from the Central Maven repository using Maven, add the following lines to pom.xml:

<dependency>
    <groupId>com.satori</groupId>
    <artifactId>satori-rtm-sdk</artifactId>
    <version>1.0.3</version>
</dependency>

Installing with Gradle

To install the Java SDK from the Central Maven repository using Gradle, add the following lines to build.gradle:

dependencies {
    compile group: 'com.satori', name: 'satori-rtm-sdk', version:'1.0.3'
}

Testing the Installation

To test the Java SDK installation, create a Java project in your IDE and enter the following code example to test the installation. Replace YOUR_ENDPOINT and YOUR_APPKEY with the values from your Satori project in the Dev Portal.

import com.satori.rtm.*;

public class Setup {
  static String endpoint = "YOUR_ENDPOINT​";
  static String appkey = "YOUR_APPKEY​";

  public static void main(String[] args) throws InterruptedException {
    final RtmClient client = new RtmClientBuilder(endpoint, appkey)
        .setListener(new RtmClientAdapter() {
          @Override
          public void onError(RtmClient client, Exception ex) {
            System.out.println("Error occurred: " + ex.getMessage());
          }

          @Override
          public void onConnectingError(RtmClient client, Exception ex) {
            System.out.println("Error occurred: " + ex.getMessage());
          }

          @Override
          public void onEnterConnected(RtmClient client) {
            System.out.println("Connected to Satori RTM!");
          }
        })
        .build();
    client.start();
  }
}

Python SDK Direct link

Satori provides the Python SDK through the pip package manager. The Python SDK includes a Command Line Interface (RTM CLI) that allows you to access RTM and record and play back channel data streams. Use pip to install the Python SDK and the RTM CLI and then run a sample snippet to test the installation.

The Python SDK source is available in our public GitHub repository.

To install the Python SDK, run the following command:

pip install satori-rtm-sdk​

See Satori RTM CLI for installing and using RTM CLI (command-line interface).

backports.ssl

If the SDK installation step detects Python older than 2.7.9 without a secure TLS socket implementation, the installer installs the secure replacement backports.ssl. For example, CentOS 7 has Python 2.7.5.

An OpenSSL library, Python development headers and a C compiler must be available.

Use the following commands on CentOS 7:

yum install -y epel-release
yum install -y python-pip gcc python-devel openssl-devel
pip install satori-rtm-sdk

Testing the Installation

To test the Python SDK installation, create a Python script  and enter the following code example to test the installation. Replace ENDPOINT and APPKEY with your values from the General tab for the project in the Dev Portal.

#!/usr/bin/env python

from __future__ import print_function

from satori.rtm.client import make_client

endpoint = 'YOUR_ENDPOINT'
appkey = 'YOUR_APPKEY'

def main():
    with make_client(endpoint=endpoint, appkey=appkey) as client:
        print('Connected to Satori RTM!')

if __name__ == '__main__':
    main()

C SDK Direct link

To use the C SDK, you must download and build it from source code. The steps to build and use the SDK depend on your specific platform (iOS, Windows or other) and found in the readme.

Testing the Installation

To test the C SDK installation, create a C program file and enter the following code example. Replace YOUR_ENDPOINT and YOUR_APPKEY with the values from your Satori project in the Dev Portal.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <rtm.h>

static char const *endpoint = "YOUR_ENDPOINT";
static char const *appkey = "YOUR_APPKEY";

int main(void) {
  void *memory = malloc(rtm_client_size);
  rtm_client_t *client = rtm_init(memory, &rtm_default_pdu_handler, 0);
  rtm_status rc = rtm_connect(client, endpoint, appkey);

  if (rc != RTM_OK) {
    fprintf(stderr, "Failed to connect: %s\n", rtm_error_string(rc));
    rtm_close(client);
    free(client);
    return rc;
  }
  printf("Connected to Satori RTM!\n");

  rtm_close(client);
  free(client);
}

Objective-C Wrapper (C SDK) Direct link

The C SDK can be built as a dynamic iOS framework to integrate with your iOS applications. Using this iOS framework, you can use the provided Objective-C APIs to publish and subscribe messages to RTM. There are a couple of ways for building and installing the SatoriRtmSdkWrapper framework into your own Xcode iOS project.

Installing with CocoaPods

The SatoriRtmSdkWrapper iOS framework is available as a CocoaPod. Cocoapod is a dependency manager for iOS, which automates and simplifies the process of using 3rd-party frameworks like SatoriRtmSdkWrapper in your projects. Make sure CocoaPods is installed on your computer. Then create a podfile for your project if it doesn't already exist. To install the framework:

  1. Open your Podfile and add the following dependency under the target "<your_app_target>" do section: use_frameworks! pod 'SatoriRtmSdkWrapper', :git => "https://github.com/satori-com/satori-rtm-sdk-c.git"
  2. Save your Podfile
  3. Run pod install from command line

You have now installed the SatoriRtmSdkWrapper iOS framework. Refer to Testing the Installation section to get started.


Installing with Source Code

Clone the satori-rtm-sdk-c GitHub repository.


1. Build framework

There are two options to build the framework for iOS: from command line or in Xcode IDE.

Build from command-line

$ cd ios-wrapper/SatoriRtmSdkWrapper

$ xcodebuild -project SatoriRtmSdkWrapper.xcodeproj -scheme SatoriRtmSdkWrapper-Universal -config <config-name> # where <config-name> can be Debug or Release. Default is Debug if -config option is not specified

Build in Xcode IDE​

Open SatoriRtmSdkWrapper.xcodeproj
Select SatoriRtmSdkWrapper-Universal target and build.

The SatoriRtmSdkWrapper.framework will be built under ios-wrapper/build directory  your repository location.

2. Add framework to your project

Once you build the framework, open your app's Xcode project and drag-and-drop the framework under "Embedded Binaries" section under the app's target.

 

Choose "Copy items if needed" and "Create groups" in the dialog box.

 

Your project target settings for “Embedded Binaries” and “Linked Frameworks and Libraries” should look like this.

 

Now refer to Testing the Installation section to get started.

Testing the Installation

To test the SatoriRtmSdkWrapper iOS framework installation, create a new Xcode iOS app project and enter the following method in your AppDelegate or a specific ViewController implementation of your choice. Replace ENDPOINT and APPKEY with your values from the General tab for your project in the Dev Portal.

#import <SatoriRtmSdkWrapper/SatoriRtmSdkWrapper.h>

static NSString* endpoint = @"ENDPOINT";
static NSString* appkey = @"APPKEY";

- (rtm_status)connectToRtm {
    // create a SatoriRtmConnection instance
    SatoriRtmConnection *rtm = [[SatoriRtmConnection alloc] initWithUrl:endpoint andAppkey:appkey];
    
    // connect to RTM and provide pdu data handler block.
    rtm_status status = [rtm connectWithPduHandler:^(SatoriPdu * pdu) {
        //Use pdu
    }];
    
    if (status != RTM_OK) {
        NSLog(@"Connection to RTM failed with status @%d", status);
        return status;
    }
    
    NSLog(@"Connected to RTM!");
    return status;
}

C# SDK Direct link

C# SDK supports the following platforms:

  • .NET Standard 1.3+ (Xamarin.Android, Xamarin.iOS, .NET Framework, Mono, etc)
  • Mono / .NET 4.5+
  • Unity 5.6+ (Standalone, iOS, Android)

Satori provides the C# SDK through the NuGet Gallery for all mentioned platforms, except Unity. For Unity, C# SDK is provided as assemblies. The source is available in our public GitHub repository. See the README for more information.

NuGet

To install C# SDK for Satori RTM, run the following command in the Package Manager Console. Alternatively, install the package via the user interface provided by Visual Studio or Xamarin Studio.

PM> Install-Package Satori.RTM.SDK

Unity

To install C# SDK for Satori RTM to a Unity project, copy the following files from Quickstart on GitHub to the Assets folder:

  • Link.xml
  • Newtonsoft.Json.dll
  • Satori.RTM.Unity.dll

Testing the Installation

To test the C# SDK installation, create a project in your IDE and enter the following code example. Replace YOUR_ENDPOINT and YOUR_APPKEY with the values from your Satori project in the Dev Portal.

using System;
using System.Diagnostics;
using Satori.Rtm.Client;

class Program
{
    const string endpoint = "YOUR_ENDPOINT";
    const string appkey = "YOUR_APPKEY";

    static void Main()
    {
        // Log messages from SDK to the console
        Trace.Listeners.Add(new ConsoleTraceListener());

        IRtmClient client = new RtmClientBuilder(endpoint, appkey).Build();

        client.OnEnterConnected += cn => Console.WriteLine("Connected to Satori RTM!");

        client.OnError += ex => 
            Console.WriteLine("Failed to connect: " + ex.Message);

        client.Start();

        Console.ReadKey();

        // Stop and clean up the client before exiting the program
        client.Dispose().Wait();
    }
}

Go SDK Direct link

Satori provides the Go SDK through the GitHub repository. See the README for more information.

Use a go-get tool (or any go-compatible package manager) to download the SDK:

go get github.com/satori-com/satori-rtm-sdk-go/rtm

Import the SDK in your go file:

import "github.com/satori-com/satori-rtm-sdk-go/rtm"

It is highly recommended to use tags to lock the SDK version for your project.

Testing the Installation

To test the Go SDK installation, build and run the following code example. Replace YOUR_ENDPOINT and YOUR_APPKEY with the values from your Satori project in the Dev Portal.

package main

import (
	"fmt"
	"github.com/satori-com/satori-rtm-sdk-go/rtm"
	"os"
	"sync"
)

const (
	ENDPOINT = "YOUR_ENDPOINT"
	APP_KEY  = "YOUR_APPKEY"
)

func main() {
	var wg sync.WaitGroup
	wg.Add(1)

	client, err := rtm.New(ENDPOINT, APP_KEY, rtm.Options{})
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	client.OnConnected(func() {
		fmt.Println("Connected to Satori RTM!")
		wg.Done()
	})
	client.OnError(func(err rtm.RTMError) {
		fmt.Println("Failed to connect: " + err.Reason.Error())
		wg.Done()
	})

	client.Start()
	wg.Wait()
}