summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-04-14 18:14:23 +0100
committerSimon MacMullen <simon@rabbitmq.com>2011-04-14 18:14:23 +0100
commit9dc2bed83820ef17e9257177fe3d06a2ec7c038c (patch)
tree70fe80ef62e7f45a2cf86d8a742fea8c882fe1ef
parentafa173d431ecc420a20c712cb37f7bee4591124f (diff)
downloadrabbitmq-server-9dc2bed83820ef17e9257177fe3d06a2ec7c038c.tar.gz
Allow the erlang client to remain ignorant of rabbit_event.
-rw-r--r--src/rabbit_direct.erl15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl
index 0810c762..df422c15 100644
--- a/src/rabbit_direct.erl
+++ b/src/rabbit_direct.erl
@@ -16,7 +16,7 @@
-module(rabbit_direct).
--export([boot/0, connect/4, start_channel/8]).
+-export([boot/0, connect/5, start_channel/8, disconnect/1]).
-include("rabbit.hrl").
@@ -25,7 +25,8 @@
-ifdef(use_specs).
-spec(boot/0 :: () -> 'ok').
--spec(connect/4 :: (binary(), binary(), binary(), rabbit_types:protocol()) ->
+-spec(connect/5 :: (binary(), binary(), binary(), rabbit_types:protocol(),
+ term()) ->
{'ok', {rabbit_types:user(),
rabbit_framing:amqp_table()}}).
-spec(start_channel/8 ::
@@ -33,6 +34,8 @@
rabbit_types:user(), rabbit_types:vhost(), rabbit_framing:amqp_table(),
pid()) -> {'ok', pid()}).
+-spec(disconnect/1 :: (pid()) -> 'ok').
+
-endif.
%%----------------------------------------------------------------------------
@@ -50,13 +53,14 @@ boot() ->
%%----------------------------------------------------------------------------
-connect(Username, Password, VHost, Protocol) ->
+connect(Username, Password, VHost, Protocol, Infos) ->
case lists:keymember(rabbit, 1, application:which_applications()) of
true ->
try rabbit_access_control:user_pass_login(Username, Password) of
#user{} = User ->
try rabbit_access_control:check_vhost_access(User, VHost) of
- ok -> {ok, {User,
+ ok -> rabbit_event:notify(connection_created, Infos),
+ {ok, {User,
rabbit_reader:server_properties(Protocol)}}
catch
exit:#amqp_error{name = access_refused} ->
@@ -77,3 +81,6 @@ start_channel(Number, ClientChannelPid, ConnPid, Protocol, User, VHost,
[{direct, Number, ClientChannelPid, ConnPid, Protocol, User, VHost,
Capabilities, Collector}]),
{ok, ChannelPid}.
+
+disconnect(Pid) ->
+ rabbit_event:notify(connection_closed, [{pid, Pid}]).