ejabberd-18.12:在钩子内解析数据包
ejabberd-18.12 : parse Packet inside hook
挂钩代码:
user_receive_packet({Packet, #{jid := JID} = C2SState}) ->
?INFO_MSG("~p.", [Packet]),
{Packet, C2SState}.
输出:
{message,<<"49a85099-6fa6-4aa5-84ab-bced89adf847">>,groupchat,<<"en">>,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<"localhost">>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<"localhost">>},{jid,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>},[],[{text,<<>>,<<"{\"type\":\"text\",\"payload\":{\"body\":\"a beautiful\"}}">>}],undefined,[{mam_archived,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>},<<"1549043294480251">>},{stanza_id,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>},<<"1549043294480251">>}],#{ip => {0,0,0,0,0,0,0,1},mam_archived => true,muc_sender_real_jid => {jid,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>},stanza_id => 1549043294480251}}.
我想读取 stanza_id
字段值和 mam_archived
下列出的时间戳
解析任何字段的语法是什么?
尝试:
?INFO_MSG("Stanza ID: ~p", [ maps:get(stanza_id, Packet#message.meta) ]),
挂钩代码:
user_receive_packet({Packet, #{jid := JID} = C2SState}) ->
?INFO_MSG("~p.", [Packet]),
{Packet, C2SState}.
输出:
{message,<<"49a85099-6fa6-4aa5-84ab-bced89adf847">>,groupchat,<<"en">>,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<"localhost">>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<"localhost">>},{jid,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>},[],[{text,<<>>,<<"{\"type\":\"text\",\"payload\":{\"body\":\"a beautiful\"}}">>}],undefined,[{mam_archived,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>},<<"1549043294480251">>},{stanza_id,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>},<<"1549043294480251">>}],#{ip => {0,0,0,0,0,0,0,1},mam_archived => true,muc_sender_real_jid => {jid,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>},stanza_id => 1549043294480251}}.
我想读取 stanza_id
字段值和 mam_archived
解析任何字段的语法是什么?
尝试:
?INFO_MSG("Stanza ID: ~p", [ maps:get(stanza_id, Packet#message.meta) ]),