class CPalaverMod : public CModule {
public:
- MODCONSTRUCTOR(CPalaverMod) {}
+ MODCONSTRUCTOR(CPalaverMod) {
+ AddHelpCommand();
+ AddCommand("test", static_cast<CModCommand::ModCmdFunc>(&CPalaverMod::HandleTestCommand),
+ "", "Send notifications to registered devices");
+ }
#pragma mark - Cap
return CONTINUE;
}
+#pragma mark - Commands
+
+ void HandleTestCommand(const CString& sLine) {
+ if (m_pNetwork) {
+ unsigned int count = 0;
+
+ for (std::vector<CDevice*>::const_iterator it = m_vDevices.begin();
+ it != m_vDevices.end(); ++it)
+ {
+ CDevice& device = **it;
+
+ if (device.HasNetwork(*m_pNetwork)) {
+ count++;
+ device.SendNotification(*this, "palaver", "Test notification", NULL);
+ }
+ }
+
+ PutModule("Notification sent to " + CString(count) + " clients.");
+ } else {
+ PutModule("You need to connect with a network.");
+ }
+ }
+
private:
std::vector<CDevice*> m_vDevices;