This commit is contained in:
Feng 2015-12-07 00:22:40 +08:00
parent 89a978a67a
commit 8f22b0ffbc
1 changed files with 5 additions and 2 deletions

View File

@ -224,8 +224,11 @@ publish(Msg = #mqtt_message{from = From}) ->
end.
publish(Topic, Msg) when is_binary(Topic) ->
lists:foreach(fun(#mqtt_topic{topic=Name, node=Node}) ->
rpc:cast(Node, ?ROUTER, route, [Name, Msg])
lists:foreach(fun(#mqtt_topic{topic = Name, node = Node}) ->
case Node =:= node() of
true -> ?ROUTER:route(Name, Msg);
false -> rpc:cast(Node, ?ROUTER, route, [Name, Msg])
end
end, match(Topic)).
%%------------------------------------------------------------------------------