[ejabberd] Sen message from ejabberd plugin

Alexander Kuleshov kuleshovmail at gmail.com
Thu Nov 3 10:30:54 MSK 2011


Hello,

I have simple ejabebrd plugin and i need to esn message from it.

My code:

send_message(TypeStr, BodyStr) ->
    LUser = "test1",
    LServer = "localhost",
    From1 = jlib:make_jid(LUser, LServer, "fb"),

    TUser = "test2",
    TServer = "localhost",
    To1 = jlib:make_jid(TUser, TServer, "fb"),

    FromAddress = jlib:jid_to_string(From1),
    ToAddress = jlib:jid_to_string(To1),

    XmlBody = {xmlelement, "message", [{"type", TypeStr}, {"from",
FromAddress}, {"to", ToAddress}], [{xmlelement, "body", [], [{xmlcdata,
BodyStr}]}]},
   ejabberd_router:route(From, To, XmlBody).

But i get error:

=ERROR REPORT==== 2011-11-03 13:27:12 ===
E(<0.494.0>:ejabberd_router:70) : {{badrecord,jid},

[{ejabberd_router,do_route,3},
                                                  {ejabberd_router,route,3},
                                                  {mod_poker,on_register,3},
                                                  {ejabberd_hooks,run1,3},

{ejabberd_c2s,wait_for_auth,2},
                                                 {p1_fsm,handle_msg,10},

 {proc_lib,init_p_do_apply,3}]}
when processing: {"test1 at localhost","test2 at localhost",
{xmlelement,"message",
[{"type","chat"},
  {"from","test1 at localhost/fb"},
  {"to","test2 at localhost/fb"}],
  [{xmlelement,"body",[],[{xmlcdata,"test test"}]}]}}

How can i fix it? How can i send message from ejabberd plugin?

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20111103/d45eeec5/attachment.html>


More information about the ejabberd mailing list