Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Daniel Brötzmann
python-nbxmpp
Commits
c2e09adc
Commit
c2e09adc
authored
Oct 26, 2020
by
Philipp Hörist
Browse files
Ping: Handle ping requests
parent
355e3076
Changes
1
Hide whitespace changes
Inline
Side-by-side
nbxmpp/modules/ping.py
View file @
c2e09adc
...
...
@@ -16,7 +16,9 @@
# along with this program; If not, see <http://www.gnu.org/licenses/>.
from
nbxmpp.protocol
import
Iq
from
nbxmpp.protocol
import
NodeProcessed
from
nbxmpp.namespaces
import
Namespace
from
nbxmpp.structs
import
StanzaHandler
from
nbxmpp.task
import
iq_request_task
from
nbxmpp.modules.base
import
BaseModule
from
nbxmpp.modules.util
import
process_response
...
...
@@ -27,7 +29,19 @@ class Ping(BaseModule):
BaseModule
.
__init__
(
self
,
client
)
self
.
_client
=
client
self
.
handlers
=
[]
self
.
handlers
=
[
StanzaHandler
(
name
=
'iq'
,
callback
=
self
.
_process_ping
,
typ
=
'get'
,
ns
=
Namespace
.
PING
,
priority
=
15
),
]
def
_process_ping
(
self
,
_client
,
stanza
,
properties
):
self
.
_log
.
info
(
'Send pong to %s'
,
stanza
.
getFrom
())
iq
=
stanza
.
buildSimpleReply
(
'result'
)
self
.
_client
.
send_stanza
(
iq
)
raise
NodeProcessed
@
iq_request_task
def
ping
(
self
,
jid
):
...
...
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