comparison mod_csi_battery_saver/mod_csi_battery_saver.lua @ 4048:64b7daa6c42c

mod_csi_battery_saver: Ignore CSI actions before resource bind
author tmolitor <thilo@eightysoft.de>
date Mon, 22 Jun 2020 21:35:57 +0200
parents 19c5bfc3a241
children 889e1695e935
comparison
equal deleted inserted replaced
4047:36b6e3e3f9e2 4048:64b7daa6c42c
148 return true; 148 return true;
149 end 149 end
150 150
151 module:hook("csi-client-inactive", function (event) 151 module:hook("csi-client-inactive", function (event)
152 local session = event.origin; 152 local session = event.origin;
153 if not session.resource then
154 session.log("warn", "Ignoring csi if no resource is bound!");
155 return;
156 end
153 if session.pump then 157 if session.pump then
154 session.log("debug", "mod_csi_battery_saver(%s): Client is inactive, buffering unimportant outgoing stanzas", id); 158 session.log("debug", "mod_csi_battery_saver(%s): Client is inactive, buffering unimportant outgoing stanzas", id);
155 session.pump:pause(); 159 session.pump:pause();
156 else 160 else
157 session.log("debug", "mod_csi_battery_saver(%s): Client is inactive the first time, initializing module for this session", id); 161 session.log("debug", "mod_csi_battery_saver(%s): Client is inactive the first time, initializing module for this session", id);
177 end 181 end
178 end); 182 end);
179 183
180 module:hook("csi-client-active", function (event) 184 module:hook("csi-client-active", function (event)
181 local session = event.origin; 185 local session = event.origin;
186 if not session.resource then
187 session.log("warn", "Ignoring csi if no resource is bound!");
188 return;
189 end
182 if session.pump then 190 if session.pump then
183 session.log("debug", "mod_csi_battery_saver(%s): Client is active, resuming direct delivery", id); 191 session.log("debug", "mod_csi_battery_saver(%s): Client is active, resuming direct delivery", id);
184 session.pump:resume(); 192 session.pump:resume();
185 end 193 end
186 end); 194 end);