-
Notifications
You must be signed in to change notification settings - Fork 53
/
SDK_invoker.html
247 lines (233 loc) · 11.4 KB
/
SDK_invoker.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<!--<script src="junk/sea.js"></script>-->
<!--<script src="main.js"></script>-->
<!--<script data-main="main" src="lib/require.js"></script>-->
<!--<script src="http://res.websdk.rongcloud.cn/RongIMClient-0.9.7.min.js"></script>-->
<!--<script src="http://res.websdk.rongcloud.net/RongIMClient.js"></script>-->
<!--<script src="grunt/release/RongIMClient.min.js"></script>-->
<!--<script src="http://res.websdk.rongcloud.cn/RongIMClient-0.9.9.min.js"></script>-->
<script src="grunt/online/RongIMClient.js"></script>
<!--<script src="grunt/online/voice-0.9.1.js"></script>-->
<!--<script src="SDK.js"></script>-->
<script>
/**
* 单元测试如何使用:
* 1、引用Junit.JS
* 2、调用Junit.init方法
* 3、调用Junit.baseFuncTest方法
* 可根据控制台输出的内容检查bug
*/
window.onerror=function(e,a,x){
alert(e)
};
// window.WEB_SOCKET_FORCE_FLASH=true;
window.WEB_XHR_POLLING=true;
window.onload=function(){
var val = location.search.slice(1);
var temp = val.split("=");
var appkey={
r:'z3v5yqkbv8v30',
d:'e0x9wycfx7flq'
};
RongIMClient.init('e0x9wycfx7flq');//z3v5yqkbv8v30 pvxdm17jx5ler e0x9wycfx7flq z3v5yqkbv8z90
RongIMClient.setConnectionStatusListener({//焦点判断
onChanged: function (status) {
switch (status) {
//链接成功
case RongIMClient.ConnectionStatus.CONNECTED:
//do something...
alert('链接成功');
break;
//正在链接
case RongIMClient.ConnectionStatus.CONNECTING:
alert('正在链接');
break;
//重新链接
case RongIMClient.ConnectionStatus.RECONNECT:
alert('重新链接');
break;
//其他设备登陆
case RongIMClient.ConnectionStatus.OTHER_DEVICE_LOGIN:
alert('其他设备登陆');
break;
//关闭
case RongIMClient.ConnectionStatus.CLOSURE:
alert('关闭');
break;
//未知错误
case RongIMClient.ConnectionStatus.UNKNOWN_ERROR:
alert('未知错误');
break;
//登出
case RongIMClient.ConnectionStatus.LOGOUT:
alert('登出');
break;
//用户已被封禁
case RongIMClient.ConnectionStatus.BLOCK:
alert('用户已被封禁');
break;
}
}
});
//release
var config = {
r: {
"jeams": 'bEVSfJuyK+vKcWWvsodcDs2yq+hfEluLjZ78E1qo4hGoJtlXfHETWJyjgbNQyiI7wYp5+CmaTzP+\/bv+vI++xg==', //7991
"qwe": '9ACxQKwgWXawwAKvIBbWb7I6ZiT8q7s0UEaMPWY0lMxOPhe7Hp2dtgkbUxMCkoU0HAhlPdxTPg4C80jqu46\/1Q==' //9813
}, d: {
lipo: 'TOzO1ORZdSKfz9qnv8VAG6ZMo\/KVDHrEYcpc\/b7q1ztnoRGG0NzjemycRjB5XF3Aea2rzNZnQGzgRMdJ12F0ag==', //2189
ott: 'ZnucOgwOxCFKahyttWB37qZMo\/KVDHrEYcpc\/b7q1ztnoRGG0Nzjeg1b2fUuhRY\/r261hg2zdyI+cSWhr8lNwQ==', //2180
lipo1:'qdgJAaoVbsnYFWU06H1D96ZMo\/KVDHrEYcpc\/b7q1zu7G6k5xy+HReYDc2l38PHzSTPeB5Zk3Tvn1jU6yYkozQ==', //2315
test:'WWW11ktxJpuOHuIPrq6sJbWcRSdGOdkm75rUuDrFPRtBviTKV0Rdssxrh/Wp8BIogwPDP2cj5iMn3WgfqlY0Xg==',// test
'test1':'Ys8QMjzzuBByjS/dnrAzawxF+sgwx+nTb5OwerSH+DTKgeqy+c1zc7gGyG8ZaqhV1e+qYuC2scTQXXASIKPRHw==' //test1
}
};
//'g82tas7cuHF2alD1SOxG3/S0EfBoXiTJkMl9cfDtCfJomIZVGpPHqsW/g+HuXXPhy/nyWFQiXsIHvUCNzzMZQQ=='
//'WWW11ktxJpuOHuIPrq6sJbWcRSdGOdkm75rUuDrFPRtBviTKV0Rdssxrh/Wp8BIogwPDP2cj5iMn3WgfqlY0Xg==' test
//'Ys8QMjzzuBByjS/dnrAzawxF+sgwx+nTb5OwerSH+DTKgeqy+c1zc7gGyG8ZaqhV1e+qYuC2scTQXXASIKPRHw==' test1
RongIMClient.connect(config[temp[0]][temp[1]], {
onSuccess: function (x) {
alert("connected,userid=" + x);
// RongIMClient.getInstance().syncConversationList(RongIMClient.ConversationType.PRIVATE,{
// onSuccess:function(){
// //同步成功后 显示同步后会话列表
// alert(RongIMClient.getInstance().getConversationList())
// },onError:function(){
//
// }
// })
window.PRIVATE=RongIMClient.ConversationType.PRIVATE;
window.GROUP=RongIMClient.ConversationType.GROUP;
window.DISCUSSION=RongIMClient.ConversationType.DISCUSSION;
window.CHATROOM=RongIMClient.ConversationType.CHATROOM;
window.CUSTOMER_SERVICE=RongIMClient.ConversationType.CUSTOMER_SERVICE;
},
onError: function (c) {
var info = '';
switch (c) {
case RongIMClient.callback.ErrorCode.TIMEOUT:
info = '超时';
break;
case RongIMClient.callback.ErrorCode.UNKNOWN_ERROR:
info = '未知错误';
break;
case RongIMClient.ConnectErrorStatus.UNACCEPTABLE_PROTOCOL_VERSION:
info = '不可接受的协议版本';
break;
case RongIMClient.ConnectErrorStatus.IDENTIFIER_REJECTED:
info = 'appkey不正确';
break;
case RongIMClient.ConnectErrorStatus.SERVER_UNAVAILABLE:
info = '服务器不可用';
break;
case RongIMClient.ConnectErrorStatus.TOKEN_INCORRECT:
info = 'token无效';
break;
case RongIMClient.ConnectErrorStatus.NOT_AUTHORIZED:
info = '未认证';
break;
case RongIMClient.ConnectErrorStatus.REDIRECT:
info = '重新获取导航';
break;
case RongIMClient.ConnectErrorStatus.PACKAGE_ERROR:
info = '包名错误';
break;
case RongIMClient.ConnectErrorStatus.APP_BLOCK_OR_DELETE:
info = '应用已被封禁或已被删除';
break;
case RongIMClient.ConnectErrorStatus.BLOCK:
info = '用户被封禁';
break;
case RongIMClient.ConnectErrorStatus.TOKEN_EXPIRE:
info = 'token已过期';
break;
case RongIMClient.ConnectErrorStatus.DEVICE_ERROR:
info = '设备号错误';
break;
}
console.info("失败:" + info);
}
});
RongIMClient.getInstance().setOnReceiveMessageListener({
onReceived: function (data) {
alert(data.getSenderUserId(), new Date);
received.value += data.getContent() + "\n";
}
});
window.callback = {
onSuccess: function (x) {
console.log(1, x,arguments)
}, onError: function (x) {
alert(arguments.callee.caller);
alert(2, x)
}
};
ins = RongIMClient.getInstance();
var send = document.getElementById("send");
var id = document.getElementById("userid");
var con = document.getElementById("sendcontent");
var received = document.getElementById("receivedcontent");
send.onclick = function () {
ins.sendMessage(RongIMClient.ConversationType.setValue(document.getElementById("conver").value), id.value, RongIMClient.TextMessage.obtain(con.value), null, {
onSuccess: function () {
alert("send success:" + parseInt(con.value), new Date);
con.value = parseInt(con.value) + 1;
},
onError: function (x) {
var info = '';
switch (x) {
case RongIMClient.callback.ErrorCode.TIMEOUT:
info = '超时';
break;
case RongIMClient.callback.ErrorCode.UNKNOWN_ERROR:
info = '未知错误';
break;
case RongIMClient.SendErrorStatus.REJECTED_BY_BLACKLIST:
info = '在黑名单中,无法向对方发送消息';
break;
case RongIMClient.SendErrorStatus.NOT_IN_DISCUSSION:
info = '不在讨论组中';
break;
case RongIMClient.SendErrorStatus.NOT_IN_GROUP:
info = '不在群组中';
break;
case RongIMClient.SendErrorStatus.NOT_IN_CHATROOM:
info = '不在聊天室中';
break;
default :
info = x;
break;
}
alert('发送失败:' + info);
}
});
};
var ones = document.getElementById("ones");
ones.onchange = function () {
window.ba = this.files[0];
};
}
</script>
</head>
<body>
<input type="text" id="userid" value=""><strong>用户id</strong><select id="conver" style="margin-left: 30px">
<option value="0">聊天室</option>
<option value="3">群组</option>
<option selected value="4">私聊</option>
<option value="2">讨论组</option>
<option value="1">客服</option>
<option value="5">系统</option>
</select><label>会话类型</label>
<textarea id="sendcontent" style="width: 100%;height: 100px;margin-top: 10px">1
</textarea><strong>接受的内容:</strong>
<textarea id="receivedcontent" style="width: 100%;height: 100px;margin-top: 10px">
</textarea>
<button id="send">send</button>
<input type="file" id="ones">
<input type="checkbox" value="0">asdfdf
</body>
</html>