0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-29 20:28:52 +02:00

modules/s_listen: Improve various.

This commit is contained in:
Jason Volk 2018-08-15 23:41:12 -07:00
parent 8603ccf16b
commit 4793545dc2
2 changed files with 33 additions and 22 deletions

View file

@ -66,11 +66,13 @@ s_moduledir = @moduledir@
s_conf_la_SOURCES = s_conf.cc
s_control_la_SOURCES = s_control.cc
s_node_la_SOURCES = s_node.cc
s_listen_la_SOURCES = s_listen.cc
s_module_LTLIBRARIES = \
s_conf.la \
s_control.la \
s_node.la \
s_listen.la \
###
###############################################################################

View file

@ -10,8 +10,10 @@
using namespace ircd;
static void create_listener(const m::event &);
extern "C" std::list<net::listener> listeners;
static void init_listener(const string_view &, const json::object &);
static void init_listener(const m::event &);
static void init_listeners();
static void on_load();
@ -21,7 +23,8 @@ IRCD_MODULE
"Server listeners", on_load
};
std::list<net::listener>
/// Active listener state
decltype(listeners)
listeners;
//
@ -50,17 +53,7 @@ init_listeners()
m::room::state{m::my_room}.for_each("ircd.listen", []
(const m::event &event)
{
const string_view &name
{
at<"state_key"_>(event)
};
const json::object &opts
{
json::get<"content"_>(event)
};
init_listener(name, opts);
init_listener(event);
});
if(listeners.empty())
@ -70,6 +63,22 @@ init_listeners()
};
}
void
init_listener(const m::event &event)
{
const string_view &name
{
at<"state_key"_>(event)
};
const json::object &opts
{
json::get<"content"_>(event)
};
init_listener(name, opts);
}
void
init_listener(const string_view &name,
const json::object &opts)
@ -93,19 +102,19 @@ init_listener(const string_view &name,
//
//
static void
create_listener(const m::event &event)
{
init_listener(event);
}
const m::hookfn<>
create_listener_hook
{
create_listener,
{
{ "_site", "vm.notify" },
{ "room_id", "!ircd" },
{ "type", "m.room.create" },
{ "_site", "vm.notify" },
{ "room_id", "!ircd" },
{ "type", "ircd.listen" },
}
};
void
create_listener(const m::event &)
{
}