From 8f22b0ffbc17336ad922644323934650ac4a2e9e Mon Sep 17 00:00:00 2001 From: Feng Date: Mon, 7 Dec 2015 00:22:40 +0800 Subject: [PATCH] route --- src/emqttd_pubsub.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/emqttd_pubsub.erl b/src/emqttd_pubsub.erl index 83bfbb510..235d78be3 100644 --- a/src/emqttd_pubsub.erl +++ b/src/emqttd_pubsub.erl @@ -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)). %%------------------------------------------------------------------------------