]> granicus.if.org Git - ejabberd/commitdiff
External Component Hook
authorxmppjingle <barata7@gmail.com>
Thu, 21 Jul 2016 17:03:01 +0000 (14:03 -0300)
committerxmppjingle <barata7@gmail.com>
Thu, 21 Jul 2016 17:03:01 +0000 (14:03 -0300)
Changed Hook Trigger Event and included a Reason upon
component_disconnected/2 Hook

src/ejabberd_service.erl

index 36047556599631651cade981dfa58583c5dc7f34..9d72b17b4b89df0ef04fa096c06caf32bc5fa924 100644 (file)
@@ -290,19 +290,13 @@ stream_established({xmlstreamelement, El}, StateData) ->
     end,
     {next_state, stream_established, StateData};
 stream_established({xmlstreamend, _Name}, StateData) ->
-       ejabberd_hooks:run(component_disconnected,
-               [StateData#state.host]),
     {stop, normal, StateData};
 stream_established({xmlstreamerror, _}, StateData) ->
-       ejabberd_hooks:run(component_disconnected,
-               [StateData#state.host]),
     send_text(StateData,
              <<(?INVALID_XML_ERR)/binary,
                (?STREAM_TRAILER)/binary>>),
     {stop, normal, StateData};
 stream_established(closed, StateData) ->
-       ejabberd_hooks:run(component_disconnected,
-               [StateData#state.host]),
     {stop, normal, StateData}.
 
 %%----------------------------------------------------------------------
@@ -390,7 +384,9 @@ terminate(Reason, StateName, StateData) ->
     case StateName of
       stream_established ->
          lists:foreach(fun (H) ->
-                               ejabberd_router:unregister_route(H)
+                               ejabberd_router:unregister_route(H),
+                               ejabberd_hooks:run(component_disconnected,
+                                       [StateData#state.host, Reason])
                        end,
                        dict:fetch_keys(StateData#state.host_opts));
       _ -> ok