Module creation, message routing
This commit is contained in:
parent
bc2dc9bf07
commit
c605b3ba93
14 changed files with 154 additions and 26 deletions
|
@ -3,7 +3,33 @@
|
|||
|
||||
#include "module.h"
|
||||
|
||||
Module::Module::Module()
|
||||
#include "gloox/message.h"
|
||||
|
||||
Module::Module::Module(const std::shared_ptr<gloox::Client>& client):
|
||||
client(client)
|
||||
{}
|
||||
|
||||
Module::Module::~Module() noexcept {}
|
||||
|
||||
std::vector<std::string> Module::Module::split(const std::string& string, const std::string& delimiter) {
|
||||
std::vector<std::string> result;
|
||||
|
||||
std::size_t last = 0;
|
||||
std::size_t next = string.find(delimiter, last);
|
||||
while (next != std::string::npos) {
|
||||
result.emplace_back(string.substr(last, next - last));
|
||||
last = next + 1;
|
||||
next = string.find(delimiter, last);
|
||||
}
|
||||
result.emplace_back(string.substr(last));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Module::Module::sendMessage(const std::shared_ptr<Actor>& actor, const std::string& body) {
|
||||
client->send(gloox::Message(
|
||||
gloox::Message::Chat,
|
||||
actor->jid,
|
||||
body
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue