You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// For client-to-server connections, the client MUST NOT attempt to enable stream management until after it has completed Resource Binding unless it is resuming a previous session
231
-
streamFeatures.use("sm",NS,async(context,next)=>{
232
-
// Resuming
233
-
if(sm.id){
234
-
try{
235
-
constelement=awaitresume(entity,sm);
236
-
awaitresumed(element);
237
-
return;
238
-
// If resumption fails, continue with session establishment
239
-
}catch{
240
-
failed();
241
-
}
242
-
}
243
-
244
-
// Enabling
245
-
246
-
// Resource binding first
247
-
awaitnext();
248
-
249
-
constpromiseEnable=enable(entity,sm);
250
-
251
-
if(sm.outbound_q.length>0){
252
-
thrownewError(
253
-
"Stream Management assertion failure, queue should be empty after enable",
254
-
);
255
-
}
256
-
257
-
// > The counter for an entity's own sent stanzas is set to zero and started after sending either <enable/> or <enabled/>.
// For client-to-server connections, the client MUST NOT attempt to enable stream management until after it has completed Resource Binding unless it is resuming a previous session
16
+
streamFeatures.use("sm",NS,async(context,next)=>{
17
+
// Resuming
18
+
if(sm.id){
19
+
try{
20
+
constelement=awaitresume(entity,sm);
21
+
awaitresumed(element);
22
+
return;
23
+
// If resumption fails, continue with session establishment
24
+
}catch{
25
+
failed();
26
+
}
27
+
}
28
+
29
+
// Enabling
30
+
31
+
// Resource binding first
32
+
awaitnext();
33
+
34
+
constpromiseEnable=enable(entity,sm);
35
+
36
+
if(sm.outbound_q.length>0){
37
+
thrownewError(
38
+
"Stream Management assertion failure, queue should be empty after enable",
39
+
);
40
+
}
41
+
42
+
// > The counter for an entity's own sent stanzas is set to zero and started after sending either <enable/> or <enabled/>.
43
+
sm.outbound=0;
44
+
45
+
try{
46
+
constresponse=awaitpromiseEnable;
47
+
enabled(response.attrs);
48
+
}catch{
49
+
sm.enabled=false;
50
+
}
51
+
52
+
sm.inbound=0;
53
+
});
54
+
}
55
+
56
+
exportfunctionenable(entity,sm){
57
+
returnprocedure(entity,makeEnableElement({ sm }),(element,done)=>{
58
+
if(element.is("enabled",NS)){
59
+
returndone(element);
60
+
}elseif(element.is("failed",NS)){
61
+
throwXMPPError.fromElement(element);
62
+
}
63
+
});
64
+
}
65
+
66
+
exportasyncfunctionresume(entity,sm){
67
+
returnprocedure(entity,makeResumeElement({ sm }),(element,done)=>{
0 commit comments