@@ -254,7 +254,7 @@ unmapped({call, From}, {attach, Attach},
254254begin_sent (cast , # 'v1_0.begin' {remote_channel = {ushort , RemoteChannel },
255255 next_outgoing_id = {uint , NOI },
256256 incoming_window = {uint , InWindow },
257- outgoing_window = {uint , OutWindow }},
257+ outgoing_window = {uint , OutWindow }} = Begin ,
258258 # state {early_attach_requests = EARs } = State ) ->
259259
260260 State1 = State # state {remote_channel = RemoteChannel },
@@ -264,7 +264,7 @@ begin_sent(cast, #'v1_0.begin'{remote_channel = {ushort, RemoteChannel},
264264 S2
265265 end , State1 , EARs ),
266266
267- ok = notify_session_begun (State2 ),
267+ ok = notify_session_begun (Begin , State2 ),
268268
269269 {next_state , mapped , State2 # state {early_attach_requests = [],
270270 next_incoming_id = NOI ,
@@ -291,18 +291,17 @@ mapped(cast, {flow_session, Flow0 = #'v1_0.flow'{incoming_window = {uint, Incomi
291291 outgoing_window = ? UINT_OUTGOING_WINDOW },
292292 ok = send (Flow , State ),
293293 {keep_state , State # state {incoming_window = IncomingWindow }};
294- mapped (cast , # 'v1_0.end' {error = Err } , State ) ->
294+ mapped (cast , # 'v1_0.end' {} = End , State ) ->
295295 % % We receive the first end frame, reply and terminate.
296296 _ = send_end (State ),
297297 % TODO: send notifications for links?
298- Reason = reason (Err ),
299- ok = notify_session_ended (State , Reason ),
298+ ok = notify_session_ended (End , State ),
300299 {stop , normal , State };
301300mapped (cast , # 'v1_0.attach' {name = {utf8 , Name },
302301 initial_delivery_count = IDC ,
303302 handle = {uint , InHandle },
304303 role = PeerRoleBool ,
305- max_message_size = MaybeMaxMessageSize },
304+ max_message_size = MaybeMaxMessageSize } = Attach ,
306305 # state {links = Links , link_index = LinkIndex ,
307306 link_handle_index = LHI } = State0 ) ->
308307
@@ -311,7 +310,7 @@ mapped(cast, #'v1_0.attach'{name = {utf8, Name},
311310 LinkIndexKey = {OurRole , Name },
312311 #{LinkIndexKey := OutHandle } = LinkIndex ,
313312 #{OutHandle := Link0 } = Links ,
314- ok = notify_link_attached (Link0 ),
313+ ok = notify_link_attached (Link0 , Attach , State0 ),
315314
316315 {DeliveryCount , MaxMessageSize } =
317316 case Link0 of
@@ -334,13 +333,11 @@ mapped(cast, #'v1_0.attach'{name = {utf8, Name},
334333 link_index = maps :remove (LinkIndexKey , LinkIndex ),
335334 link_handle_index = LHI #{InHandle => OutHandle }},
336335 {keep_state , State };
337- mapped (cast , # 'v1_0.detach' {handle = {uint , InHandle },
338- error = Err },
336+ mapped (cast , # 'v1_0.detach' {handle = {uint , InHandle }} = Detach ,
339337 # state {links = Links , link_handle_index = LHI } = State0 ) ->
340338 with_link (InHandle , State0 ,
341339 fun (# link {output_handle = OutHandle } = Link , State ) ->
342- Reason = reason (Err ),
343- ok = notify_link_detached (Link , Reason ),
340+ ok = notify_link_detached (Link , Detach , State ),
344341 {keep_state ,
345342 State # state {links = maps :remove (OutHandle , Links ),
346343 link_handle_index = maps :remove (InHandle , LHI )}}
@@ -552,9 +549,8 @@ mapped(_EvtType, Msg, _State) ->
552549 [Msg , 10 ]),
553550 keep_state_and_data .
554551
555- end_sent (_EvtType , # 'v1_0.end' {error = Err }, State ) ->
556- Reason = reason (Err ),
557- ok = notify_session_ended (State , Reason ),
552+ end_sent (_EvtType , # 'v1_0.end' {} = End , State ) ->
553+ ok = notify_session_ended (End , State ),
558554 {stop , normal , State };
559555end_sent (_EvtType , _Frame , _State ) ->
560556 % just drop frames here
@@ -989,22 +985,51 @@ maybe_notify_link_credit(#link{role = sender,
989985maybe_notify_link_credit (_Old , _New ) ->
990986 ok .
991987
992- notify_link_attached (Link ) ->
993- notify_link (Link , attached ).
994-
995- notify_link_detached (Link , Reason ) ->
988+ notify_link_attached (Link , Perf , # state {connection_config = Cfg }) ->
989+ What = case Cfg of
990+ #{notify_with_performative := true } ->
991+ {attached , Perf };
992+ _ ->
993+ attached
994+ end ,
995+ notify_link (Link , What ).
996+
997+ notify_link_detached (Link ,
998+ Perf = # 'v1_0.detach' {error = Err },
999+ # state {connection_config = Cfg }) ->
1000+ Reason = case Cfg of
1001+ #{notify_with_performative := true } ->
1002+ Perf ;
1003+ _ ->
1004+ reason (Err )
1005+ end ,
9961006 notify_link (Link , {detached , Reason }).
9971007
9981008notify_link (# link {notify = Pid , ref = Ref }, What ) ->
9991009 Evt = {amqp10_event , {link , Ref , What }},
10001010 Pid ! Evt ,
10011011 ok .
10021012
1003- notify_session_begun (# state {notify = Pid }) ->
1004- Pid ! amqp10_session_event (begun ),
1013+ notify_session_begun (Perf , # state {notify = Pid ,
1014+ connection_config = Cfg }) ->
1015+ Evt = case Cfg of
1016+ #{notify_with_performative := true } ->
1017+ {begun , Perf };
1018+ _ ->
1019+ begun
1020+ end ,
1021+ Pid ! amqp10_session_event (Evt ),
10051022 ok .
10061023
1007- notify_session_ended (# state {notify = Pid }, Reason ) ->
1024+ notify_session_ended (Perf = # 'v1_0.end' {error = Err },
1025+ # state {notify = Pid ,
1026+ connection_config = Cfg }) ->
1027+ Reason = case Cfg of
1028+ #{notify_with_performative := true } ->
1029+ Perf ;
1030+ _ ->
1031+ reason (Err )
1032+ end ,
10081033 Pid ! amqp10_session_event ({ended , Reason }),
10091034 ok .
10101035
0 commit comments