imobile_for_javascript
Version:
iMobile for JavaScript,是SuperMap iMobile推出的一款基于React-Native框架的移动应用开发工具。基于该开发工具,用户可以使用JavaScript开发语言,开发出在Android和IOS操作系统下运行的原生移动GIS应用,入门门槛低,一次开发,处处运行。
112 lines (106 loc) • 2.8 kB
JavaScript
/**
* Created by will on 2016/7/5.
*/
import {NativeModules} from 'react-native';
let SPM = NativeModules.JSSTOMPManager;
import STOMPSender from './STOMPSender.js';
import STOMPReceiver from './STOMPReceiver.js';
/**
* @class STOMPManager
*/
export default class STOMPManager{
/**
* 创建一个AMQPManager对象
* @memberOf STOMPManager
* @returns {Promise.<AMQPManager>}
*/
async createObj(){
try{
var {_STOMPManagerId} = await SPM.createObj();
var STOMPManagerObj = new STOMPManager();
STOMPManagerObj.STOMPManagerId = _STOMPManagerId;
return STOMPManagerObj;
}catch(e){
console.error(e);
}
}
/**
* 初始化库。
* @memberOf STOMPManager
* @returns {Promise.<AMQPReceiver>}
*/
async initializeLibrary(){
try{
await SPM.initializeLibrary();
}catch(e){
console.error(e);
}
}
/**
* 释放环境。不可重复释放。
* @memberOf STOMPManager
* @returns {Promise.<AMQPReceiver>}
*/
async shutdownLibrary(){
try{
await SPM.shutdownLibrary();
}catch(e){
console.error(e);
}
}
/**
* 创建一个发送端
* @memberOf STOMPManager
* @returns {Promise.<AMQPSender>}
*/
async newSender(useTopic,name){
try{
var {STOMPSenderId} = await SPM.newSender(this.STOMPManagerId,useTopic,name);
var newSPS = new STOMPSender();
newSPS.STOMPSenderId = STOMPSenderId;
return newSPS;
}catch(e){
console.error(e);
}
}
/**
* 创建一个接收端
* @memberOf STOMPManager
* @returns {Promise.<AMQPSender>}
*/
async newReceiver(useTopic,name,clientID){
try{
var {STOMPReceiverId} = await SPM.newReceiver(this.STOMPManagerId,useTopic,name,clientID);
var newSPR = new STOMPReceiver();
newSPR.STOMPReceiverId = STOMPReceiverId;
return newSPS;
}catch(e){
console.error(e);
}
}
/**
* 建立链接
* @memberOf STOMPManager
* @returns {Promise.<bool>}
*/
async connection(URI,userName,passWord){
try{
var {isConnection} = await SPM.connection(this.STOMPManagerId,URI,userName,passWord);
return isConnection;
}catch(e){
console.error(e);
}
}
/**
* 断开链接
* @memberOf STOMPManager
* @returns {Promise.<bool>}
*/
async disconnection(){
try{
await SPM.disconnection(this.STOMPManagerId);
}catch(e){
console.error(e);
}
}
}