This repository has been archived by the owner on Nov 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 495
/
init-muti.html
103 lines (94 loc) · 2.34 KB
/
init-muti.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>im init</title>
</head>
<body>
<style>
td{
text-align:left;
}
pre{
display:inline-block;
width:500px;
font-size:12px;
line-height:1.5;
font-family:verdana;
padding:5px;
background:#f5f5f5;
border:1px solid #333;
overflow:hidden;
}
</style>
<h1>IM 初始化的回调队列</h1>
<h3>发消息页面(使用默认配置) <a href="https://rongcloud.github.io/websdk-demo/api-test.html">https://rongcloud.github.io/websdk-demo/api-test.html</a></h3>
<table>
<tr>
<td id="t1"></td>
<td id="t2"></td>
</tr>
<tr>
<td><pre id="m1"></pre></td>
<td><pre id="m2"></pre></td>
</tr>
</table>
<script src="//cdn.ronghub.com/RongIMLib-2.5.4.js"></script>
<script src="init-muti.js"></script>
<script>
var appInfo = {
appKey : "8w7jv4qb78a9y",
token : "ZThhLI1Xa1BX5EMREAdArWSH6ouuI8NT/fNmMkzF+4IOKIoFvbsi6JnH8QmnSltLkCcsK8vOgKl3IZgfbxFiWg=="
};
//第一次注册调用
var message1 = [];
var callbacks1 = {
onReady : function(instance){
console.log("第一次 instance");
console.log(instance);
},
onConnect : function(userInfo){
console.log("第一次 userInfo");
console.log(userInfo);
userId = userInfo.data.userId;
document.getElementById("t1").innerHTML = "第一次调动,userId = " + userId;
},
onMessage : function(message){
console.log("第一次注册 接收新消息");
console.log(message.messageUId);
console.log(message);
message1.push(message);
message1 = message1.splice(0,3);
document.getElementById("m1").innerHTML = JSON.stringify(message1,null," ");
}
};
initMuti(callbacks1,appInfo);
//第二次注册调用
var message2 = [];
var callbacks2 = {
onReady : function(instance){
console.log("第二次 instance");
console.log(instance);
},
onConnect : function(userInfo){
console.log("第二次 userInfo");
console.log(userInfo);
userId = userInfo.data.userId;
document.getElementById("t2").innerHTML = "第二次调动,userId = " + userId;
},
onMessage : function(message){
console.log("第二次注册 接收新消息");
console.log(message.messageUId);
console.log(message);
message2.push(message);
message2 = message2.splice(0,3);
document.getElementById("m2").innerHTML = JSON.stringify(message2,null," ");
}
};
//第二次无需appInfo
setTimeout(function(){
initMuti(callbacks2);
},0);
</script>
</body>
</html>