Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
3aefba32
Commit
3aefba32
authored
Mar 21, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change ping plugin to not have to use overrides.
Had to add a `reconnect` event to core.
parent
82aa9fec
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
39 deletions
+34
-39
docs/source/development.rst
docs/source/development.rst
+6
-4
spec/ping.js
spec/ping.js
+20
-14
src/converse-core.js
src/converse-core.js
+1
-0
src/converse-ping.js
src/converse-ping.js
+7
-21
No files found.
docs/source/development.rst
View file @
3aefba32
...
...
@@ -862,12 +862,14 @@ When keepalive=true but there aren't any stored prebind tokens.
``converse.listen.on('noResumeableSession', function (event) { ... });``
reconnect
~~~~~~~~~
reconnect
ed
~~~~~~~~~
~~
After the connection has dropped. Converse.js will attempt to reconnect when not in prebind mode.
After the connection has dropped and converse.js has reconnected.
Any Strophe stanza handlers (as registered via `converse.listen.stanza`) will
have to be registered anew.
``converse.listen.on('reconnect', function (event) { ... });``
``converse.listen.on('reconnect
ed
', function (event) { ... });``
roomInviteSent
~~~~~~~~~~~~~~
...
...
spec/ping.js
View file @
3aefba32
...
...
@@ -2,28 +2,34 @@
(
function
(
root
,
factory
)
{
define
([
"
jquery
"
,
"
mock
"
,
"
test_utils
"
,
"
converse-ping
"
],
function
(
$
,
mock
,
test_utils
)
{
return
factory
(
$
,
mock
,
test_utils
);
],
function
(
$
)
{
return
factory
(
$
);
}
);
}
(
this
,
function
(
$
,
mock
,
test_utils
)
{
}
(
this
,
function
(
$
)
{
"
use strict
"
;
describe
(
"
XMPP Ping
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
describe
(
"
Ping and pong handlers
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
it
(
"
are registered when converse.js is
initialized
"
,
$
.
proxy
(
function
()
{
describe
(
"
XMPP Ping
"
,
function
(
)
{
describe
(
"
Ping and pong handlers
"
,
function
(
)
{
it
(
"
are registered when converse.js is
connected
"
,
function
()
{
spyOn
(
converse
,
'
registerPingHandler
'
).
andCallThrough
();
spyOn
(
converse
,
'
registerPongHandler
'
).
andCallThrough
();
converse
.
_initialize
(
);
converse
.
emit
(
'
connected
'
);
expect
(
converse
.
registerPingHandler
).
toHaveBeenCalled
();
expect
(
converse
.
registerPongHandler
).
toHaveBeenCalled
();
},
converse
,
mock
,
test_utils
));
}));
});
it
(
"
are registered when converse.js reconnected
"
,
function
()
{
spyOn
(
converse
,
'
registerPingHandler
'
).
andCallThrough
();
spyOn
(
converse
,
'
registerPongHandler
'
).
andCallThrough
();
converse
.
emit
(
'
reconnected
'
);
expect
(
converse
.
registerPingHandler
).
toHaveBeenCalled
();
expect
(
converse
.
registerPongHandler
).
toHaveBeenCalled
();
});
});
describe
(
"
An IQ stanza
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
describe
(
"
An IQ stanza
"
,
function
(
)
{
it
(
"
is sent out when converse.js pings a server
"
,
function
()
{
var
sent_stanza
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
...
...
@@ -37,6 +43,6 @@
"
<ping xmlns='urn:xmpp:ping'/>
"
+
"
</iq>
"
);
});
})
)
;
}
,
converse
,
mock
,
test_utils
)
);
});
});
}));
src/converse-core.js
View file @
3aefba32
...
...
@@ -626,6 +626,7 @@
this
.
afterReconnected
();
deferred
.
resolve
();
}.
bind
(
this
));
converse
.
emit
(
'
reconnected
'
);
return
deferred
.
promise
();
};
...
...
src/converse-ping.js
View file @
3aefba32
...
...
@@ -24,27 +24,6 @@
converse_api
.
plugins
.
add
(
'
ping
'
,
{
overrides
:
{
// Overrides mentioned here will be picked up by converse.js's
// plugin architecture they will replace existing methods on the
// relevant objects or classes.
//
// New functions which don't exist yet can also be added.
onConnected
:
function
()
{
var
promise
=
this
.
_super
.
onConnected
();
promise
.
done
(
converse
.
registerPingHandler
);
return
promise
;
},
onReconnected
:
function
()
{
// We need to re-register the ping event handler on the newly
// created connection.
var
promise
=
this
.
_super
.
onReconnected
();
promise
.
done
(
converse
.
registerPingHandler
);
return
promise
;
}
},
initialize
:
function
()
{
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
...
...
@@ -118,6 +97,13 @@
converse
.
ping
(
jid
);
}
});
var
onConnected
=
function
()
{
// Wrapper so that we can spy on registerPingHandler in tests
converse
.
registerPingHandler
();
};
converse
.
on
(
'
connected
'
,
onConnected
);
converse
.
on
(
'
reconnected
'
,
onConnected
);
}
});
}));
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