Merge pull request #6986 from HJianBo/more-fields-for-client-online-offline
feat(event): add `connected_at` into client_disconnected event
This commit is contained in:
commit
3f8c0072ce
|
@ -109,8 +109,7 @@ on_client_connected(ClientInfo, ConnInfo) ->
|
||||||
Payload = Payload0#{
|
Payload = Payload0#{
|
||||||
keepalive => maps:get(keepalive, ConnInfo, 0),
|
keepalive => maps:get(keepalive, ConnInfo, 0),
|
||||||
clean_start => maps:get(clean_start, ConnInfo, true),
|
clean_start => maps:get(clean_start, ConnInfo, true),
|
||||||
expiry_interval => maps:get(expiry_interval, ConnInfo, 0),
|
expiry_interval => maps:get(expiry_interval, ConnInfo, 0)
|
||||||
connected_at => maps:get(connected_at, ConnInfo)
|
|
||||||
},
|
},
|
||||||
publish_event_msg(<<"$event/client_connected">>, Payload).
|
publish_event_msg(<<"$event/client_connected">>, Payload).
|
||||||
|
|
||||||
|
@ -210,14 +209,17 @@ common_infos(
|
||||||
sockport := SockPort
|
sockport := SockPort
|
||||||
},
|
},
|
||||||
_ConnInfo = #{proto_name := ProtoName,
|
_ConnInfo = #{proto_name := ProtoName,
|
||||||
proto_ver := ProtoVer
|
proto_ver := ProtoVer,
|
||||||
|
connected_at := ConnectedAt
|
||||||
}) ->
|
}) ->
|
||||||
#{clientid => ClientId,
|
#{clientid => ClientId,
|
||||||
username => Username,
|
username => Username,
|
||||||
ipaddress => ntoa(PeerHost),
|
ipaddress => ntoa(PeerHost),
|
||||||
sockport => SockPort,
|
sockport => SockPort,
|
||||||
proto_name => ProtoName,
|
proto_name => ProtoName,
|
||||||
proto_ver => ProtoVer
|
proto_ver => ProtoVer,
|
||||||
|
connected_at => ConnectedAt,
|
||||||
|
ts => erlang:system_time(millisecond)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
make_msg(Topic, Payload) ->
|
make_msg(Topic, Payload) ->
|
||||||
|
|
Loading…
Reference in New Issue