input message format

Hello,

I'm writing module for ejabberd. And need to parse all input message from all users.

In which format messages go from client. For example: i need to handle message:


test 1

I need: ["test", "1"] in output.

I try:

parse(Packet)->
ParsePacket = string:tokens(Packet, " "),
[Comand, ID] = ParsePacket.

But get error:


{function_clause,
[{parse,parse,
[{xmlelement,"message",
[{"xml:lang","en"},
{"type","chat"},
{"to","localhost"},
{"id","aabda"}],
[{xmlcdata,<<"\n">>},
{xmlelement,"body",[],
[{xmlcdata,<<"test 1">>}]},
{xmlcdata,<<"\n">>},
{xmlelement,"active",
[{"xmlns",
"http://jabber.org/protocol/chatstat$
[]},
{xmlcdata,<<"\n">>}]}]},
{mod_test,route,3},
{ejabberd_router,route,3},
{ejabberd_c2s,session_established2,2},
{p1_fsm,handle_msg,10},
{proc_lib,init_p_do_apply,3}]}

Which format has input messages? Binary? List? or something else?

Thank you.

problem solved.

problem solved.

shk wrote: Which format has

shk wrote:

Which format has input messages? Binary? List? or something else?

This is mentioned in the "Ejabberd 2.1.x Developers Guide" file dev.html, section "5 XML Representation".

Syndicate content