Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xmpp-pane
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Adrien Dorsaz
xmpp-pane
Commits
aca7c79a
Commit
aca7c79a
authored
Jun 07, 2018
by
Adrien Dorsaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmpp: manage stream close from client
parent
a0e2bcce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
2 deletions
+31
-2
src/xmpp-pane-main.js
src/xmpp-pane-main.js
+8
-0
src/xmpp/client.js
src/xmpp/client.js
+6
-1
src/xmpp/core/stream.js
src/xmpp/core/stream.js
+3
-0
src/xmpp/websocket/framed-stream.js
src/xmpp/websocket/framed-stream.js
+14
-1
No files found.
src/xmpp-pane-main.js
View file @
aca7c79a
...
...
@@ -127,6 +127,14 @@ xmppClientListener = function (message, sender, sendResponse) {
);
break
;
case
'
disconnect
'
:
xmppPaneClient
.
close
();
sendResponse
({
connected
:
false
});
break
;
case
'
exploreServer
'
:
asynchroneResponse
=
true
;
xmppPaneClient
.
discoPubsubService
(
message
.
payload
)
...
...
src/xmpp/client.js
View file @
aca7c79a
...
...
@@ -24,8 +24,13 @@ class Client {
this
.
password
=
_config
.
password
;
delete
this
.
config
.
password
;
this
.
init
();
}
// To go back or to construct the intial client state
init
()
{
// optional websocketURL
this
.
websocketURL
=
_
config
.
websocketURL
;
this
.
websocketURL
=
this
.
config
.
websocketURL
;
// DOM toolbox
this
.
dom
=
document
.
implementation
.
createDocument
(
null
,
null
);
...
...
src/xmpp/core/stream.js
View file @
aca7c79a
...
...
@@ -18,6 +18,9 @@ class Stream {
// XML DOM tree (cleared each time)
this
.
dom
=
document
.
implementation
.
createDocument
(
null
,
null
);
// Closing state
this
.
isClosing
=
false
;
// DOM Parser can parse XML string to DOM (created once)
if
(
!
this
.
domParser
)
{
this
.
domParser
=
new
DOMParser
();
...
...
src/xmpp/websocket/framed-stream.js
View file @
aca7c79a
...
...
@@ -56,6 +56,9 @@ class FramedStream extends Stream {
*/
close
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// Save we are closing to avoid send again the same message
this
.
isClosing
=
true
;
let
close
=
this
.
dom
.
createElementNS
(
Constants
.
NS_XMPP_FRAMING
,
"
close
"
);
close
.
setAttribute
(
"
to
"
,
this
.
to
);
close
.
setAttribute
(
"
version
"
,
Constants
.
XMPP_VERSION
);
...
...
@@ -78,7 +81,17 @@ class FramedStream extends Stream {
// Initiate close when receiving <close>
// <close> can contain see-other-uri to redirect the stream
// (be careful to keep same security at least in that case)
xmppClient
.
close
();
if
(
this
.
isClosing
)
{
// Well we asked to close and the close has been aknowleged
console
.
log
(
'
framed-stream: received <close> after self-initiated close: reinit client.
'
);
xmppClient
.
init
();
}
else
{
// We didn't initiate the close, call close and reinit directly the client
console
.
log
(
'
framed-stream: received <close> from server: acknowledge and reinit client.
'
);
xmppClient
.
close
();
xmppClient
.
init
();
}
break
;
default
:
super
.
handle
(
xmppClient
,
message
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment