mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Pick first local multicast service, otherwise remote (ejabberd-contrib#105)
This commit is contained in:
parent
7206bff4a4
commit
fe10c6f6f2
@ -202,14 +202,18 @@ do_route(From, Domain, Destinations, Packet) ->
|
|||||||
%% If no multicast service is available in this server, send manually
|
%% If no multicast service is available in this server, send manually
|
||||||
[] -> do_route_normal(From, Destinations, Packet);
|
[] -> do_route_normal(From, Destinations, Packet);
|
||||||
|
|
||||||
%% If available, send the packet using multicast service
|
%% If some is available, send the packet using multicast service
|
||||||
[R] ->
|
Rs when is_list(Rs) ->
|
||||||
case R#route_multicast.pid of
|
Pid = pick_multicast_pid(Rs),
|
||||||
Pid when is_pid(Pid) ->
|
Pid ! {route_trusted, From, Destinations, Packet}
|
||||||
Pid ! {route_trusted, From, Destinations, Packet};
|
|
||||||
_ -> do_route_normal(From, Destinations, Packet)
|
|
||||||
end
|
|
||||||
end.
|
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) ->
|
do_route_normal(From, Destinations, Packet) ->
|
||||||
[ejabberd_router:route(From, To, Packet) || To <- Destinations].
|
[ejabberd_router:route(From, To, Packet) || To <- Destinations].
|
||||||
|
Loading…
Reference in New Issue
Block a user