Mercurial > prosody-modules
comparison mod_http_stats_stream/mod_http_stats_stream.lua @ 3643:740870196b97
mod_http_stats_stream: Make global to simplify
The stats are all global anyways and HTTP modules can now be global.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 09 Aug 2019 19:00:35 +0200 |
| parents | fd054689a64c |
| children | bac3dae031ee |
comparison
equal
deleted
inserted
replaced
| 3642:2bbf655431be | 3643:740870196b97 |
|---|---|
| 1 module:set_global(); | |
| 2 | |
| 1 local statsman = require "core.statsmanager"; | 3 local statsman = require "core.statsmanager"; |
| 2 local http = require "net.http.server"; | 4 local http = require "net.http.server"; |
| 3 local json = require "util.json"; | 5 local json = require "util.json"; |
| 4 | 6 |
| 5 local sessions = {}; | 7 local sessions = {}; |
| 26 sessions[response] = request; | 28 sessions[response] = request; |
| 27 return true; | 29 return true; |
| 28 end | 30 end |
| 29 | 31 |
| 30 | 32 |
| 31 module:hook_global("stats-updated", function (event) | 33 module:hook("stats-updated", function (event) |
| 32 local data = table.concat({ | 34 local data = table.concat({ |
| 33 "event: stats-updated"; | 35 "event: stats-updated"; |
| 34 "data: "..json.encode(event.changed_stats); | 36 "data: "..json.encode(event.changed_stats); |
| 35 ""; | 37 ""; |
| 36 ""; | 38 ""; |
