Mercurial > prosody-modules
annotate mod_csi/mod_csi.lua @ 3607:3a06b0b6ba67
mod_statistics_statsman: Update for change stats type change in mod_measure_memory
See a5a5f85d7ca1
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 28 May 2019 21:15:09 +0200 |
parents | eaf0b1e95016 |
children |
rev | line source |
---|---|
1483
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local st = require "util.stanza"; |
1590
fbb4cd2922a1
mod_csi: Update namespace to published version
Kim Alvefur <zash@zash.se>
parents:
1483
diff
changeset
|
2 local xmlns_csi = "urn:xmpp:csi:0"; |
fbb4cd2922a1
mod_csi: Update namespace to published version
Kim Alvefur <zash@zash.se>
parents:
1483
diff
changeset
|
3 local csi_feature = st.stanza("csi", { xmlns = xmlns_csi }); |
1483
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 module:hook("stream-features", function (event) |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 if event.origin.username then |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 event.features:add_child(csi_feature); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 end |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 end); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 function refire_event(name) |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 return function (event) |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 if event.origin.username then |
3395
eaf0b1e95016
mod_csi: Backport 989cf872d5c0 from Prosody 0.11 to preserve compatibility
Matthew Wild <mwild1@gmail.com>
parents:
1590
diff
changeset
|
14 event.origin.state = event.stanza.name; |
1483
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 module:fire_event(name, event); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 return true; |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 end |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 end; |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 end |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 |
1590
fbb4cd2922a1
mod_csi: Update namespace to published version
Kim Alvefur <zash@zash.se>
parents:
1483
diff
changeset
|
21 module:hook("stanza/"..xmlns_csi..":active", refire_event("csi-client-active")); |
fbb4cd2922a1
mod_csi: Update namespace to published version
Kim Alvefur <zash@zash.se>
parents:
1483
diff
changeset
|
22 module:hook("stanza/"..xmlns_csi..":inactive", refire_event("csi-client-inactive")); |
1483
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |