react-native-autobahnjs
v0.1.6
Published
A JavaScript library for WAMP in react-native.
Downloads
28
Readme
React-native AutobahnJS
React-native AutobahnJS is based on AutobahnJS,implements the WAMP protocal in react-native environment.
WAMP provides asynchronous Remote Procedure Calls and Publish & Subscribe for applications in one protocol running over WebSocket.
AutobahnJS is part of the Autobahn project, MIT licensed, and full source code can be found on GitHub.
Code Example:
var autobahn = require('react-native-autobahnjs');
var WEBSOCKET_API_URL = 'wss://your-websocket/';
var FALLBACK_API_URL = 'https://your-fallback/';
var DOMAIN_PREFIX = 'http://your-domain-prefix';
var React = require('react-native');
var connection = new autobahn.Connection({
transports: [{
type: 'mobile', //type must be mobile in react-native
url: WEBSOCKET_API_URL,
fallback: FALLBACK_API_URL
}],
realm: DOMAIN_PREFIX
});
connection.onopen = function (session) {
//on open.
};
connection.onclose = function () {
//on close.
};
connection.open();