diff options
author | Badlop <badlop@process-one.net> | 2015-06-04 12:13:10 +0200 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2015-06-04 12:13:10 +0200 |
commit | fe10c6f6f2e28cb116f9e6f37cfb5927e49546ba (patch) | |
tree | 170dd5a7eeaca6fdb4eef8512e313e93ac90d862 /src | |
parent | Merge pull request #592 from weiss/omit-subject-body (diff) |
Pick first local multicast service, otherwise remote (ejabberd-contrib#105)
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_router_multicast.erl | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ejabberd_router_multicast.erl b/src/ejabberd_router_multicast.erl index 9cd7dd3d..373d9227 100644 --- a/src/ejabberd_router_multicast.erl +++ b/src/ejabberd_router_multicast.erl @@ -202,14 +202,18 @@ do_route(From, Domain, Destinations, Packet) -> %% If no multicast service is available in this server, send manually [] -> do_route_normal(From, Destinations, Packet); - %% If available, send the packet using multicast service - [R] -> - case R#route_multicast.pid of - Pid when is_pid(Pid) -> - Pid ! {route_trusted, From, Destinations, Packet}; - _ -> do_route_normal(From, Destinations, Packet) - end + %% If some is available, send the packet using multicast service + Rs when is_list(Rs) -> + Pid = pick_multicast_pid(Rs), + Pid ! {route_trusted, From, Destinations, Packet} end. +pick_multicast_pid(Rs) -> + List = case [R || R <- Rs, node(R#route_multicast.pid) == node()] of + [] -> Rs; + RLocals -> RLocals + end, + (hd(List))#route_multicast.pid. + do_route_normal(From, Destinations, Packet) -> [ejabberd_router:route(From, To, Packet) || To <- Destinations]. |