Repository navigation
Expand file tree
/
Copy pathSTOMPReceiver.js
More file actions
78 lines (75 loc) · 2.52 KB
/
Copy pathSTOMPReceiver.js
File metadata and controls
78 lines (75 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Created by will on 2016/7/5.
*/
import {NativeModules,DeviceEventEmitter,NativeEventEmitter,Platform} from 'react-native';
let SPR = NativeModules.JSSTOMPReceiver;
const nativeEvt = new NativeEventEmitter(SPR);
/**
* @class STOMPReceiver
*/
export default class STOMPReceiver{
/**
* 创建一个STOMPReceiver对象
* @memberOf STOMPReceiver
* @returns {Promise.<AMQPManager>}
*/
/* async createObj(){
try{
var {_STOMPReceiverId} = await SPR.createObj();
var STOMPReceiverObj = new STOMPReceiver();
STOMPReceiverObj.STOMPReceiverId = _STOMPReceiverId;
return STOMPReceiverObj;
}catch(e){
console.error(e);
}
}
*/
/**
* 接收信息
* @memberOf STOMPReceiver
* @returns {Promise.<void>}
*/
async receiveMessage(queueNum,loadingMessage){
try{
switch(queueNum){
case 1 : var str = "com.supermap.RN.JSSTOMPReceiver.receive_message1";
break;
case 2 : var str = "com.supermap.RN.JSSTOMPReceiver.receive_message2";
break;
case 3 : var str = "com.supermap.RN.JSSTOMPReceiver.receive_message3";
break;
case 4 : var str = "com.supermap.RN.JSSTOMPReceiver.receive_message4";
break;
case 5 : var str = "com.supermap.RN.JSSTOMPReceiver.receive_message5";
break;
default : var str = "com.supermap.RN.JSSTOMPReceiver.receive_message1";
}
//差异化处理
if(Platform.OS === 'ios'){
nativeEvt.addListener(str,function (e) {
if(typeof loadingMessage === 'function'){
loadingMessage(e.message);
}else{
console.error("Please set a callback function to the first argument.");
}
});
await SPR.receiveMessage(this.STOMPReceiverId,str);
}
}catch(e){
console.error(e);
}
}
/**
* 释放对象
* @memberOf STOMPReceiver
* @returns {Promise.<void>}
*/
async dispose(){
try{
var {isDispose} = await SPR.dispose(this.STOMPReceiverId);
return isDispose;
}catch(e){
console.error(e);
}
}
}