diff options
Diffstat (limited to 'src/ejabberd_router_multicast.erl')
-rw-r--r-- | src/ejabberd_router_multicast.erl | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ejabberd_router_multicast.erl b/src/ejabberd_router_multicast.erl index fa32c8ed7..c7a190670 100644 --- a/src/ejabberd_router_multicast.erl +++ b/src/ejabberd_router_multicast.erl @@ -43,9 +43,10 @@ -include("ejabberd.hrl"). -include("logger.hrl"). --include("jlib.hrl"). +-include("xmpp.hrl"). --record(route_multicast, {domain, pid}). +-record(route_multicast, {domain = <<"">> :: binary() | '_', + pid = self() :: pid()}). -record(state, {}). %%==================================================================== @@ -58,7 +59,7 @@ start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). - +-spec route_multicast(jid(), binary(), [jid()], stanza()) -> ok. route_multicast(From, Domain, Destinations, Packet) -> case catch do_route(From, Domain, Destinations, Packet) of {'EXIT', Reason} -> @@ -68,6 +69,7 @@ route_multicast(From, Domain, Destinations, Packet) -> ok end. +-spec register_route(binary()) -> any(). register_route(Domain) -> case jid:nameprep(Domain) of error -> @@ -81,6 +83,7 @@ register_route(Domain) -> mnesia:transaction(F) end. +-spec unregister_route(binary()) -> any(). unregister_route(Domain) -> case jid:nameprep(Domain) of error -> @@ -112,7 +115,7 @@ unregister_route(Domain) -> %% Description: Initiates the server %%-------------------------------------------------------------------- init([]) -> - mnesia:create_table(route_multicast, + ejabberd_mnesia:create(?MODULE, route_multicast, [{ram_copies, [node()]}, {type, bag}, {attributes, @@ -206,6 +209,7 @@ code_change(_OldVsn, State, _Extra) -> %%-------------------------------------------------------------------- %% From = #jid %% Destinations = [#jid] +-spec do_route(jid(), binary(), [jid()], stanza()) -> any(). do_route(From, Domain, Destinations, Packet) -> ?DEBUG("route_multicast~n\tfrom ~s~n\tdomain ~s~n\tdestinations ~p~n\tpacket ~p~n", @@ -226,6 +230,7 @@ do_route(From, Domain, Destinations, Packet) -> Pid ! {route_trusted, From, Destinations, Packet} end. +-spec pick_multicast_pid([#route_multicast{}]) -> pid(). pick_multicast_pid(Rs) -> List = case [R || R <- Rs, node(R#route_multicast.pid) == node()] of [] -> Rs; @@ -233,5 +238,6 @@ pick_multicast_pid(Rs) -> end, (hd(List))#route_multicast.pid. +-spec do_route_normal(jid(), [jid()], stanza()) -> any(). do_route_normal(From, Destinations, Packet) -> [ejabberd_router:route(From, To, Packet) || To <- Destinations]. |