0

如何使用 exmpp bot 登录到多用户聊天室?

尝试使用:

create_move_room (Room, Username) ->
   #xmlel {name=presence, attrs=[#xmlattr{name = to,
                                          value = list_to_binary(Room ++ "@" ++ ?           JABBER_MUC_HOST ++ "/" ++ Username)}],
                                         children=[#xmlel{name=x,attrs=[#xmlattr{name=xmlns, value="?MUC"}]}]}.

但得到错误:

** Reason for termination =
** {badarg,[{erlang,binary_to_list,[to]},
           {exmpp_xml,xmlnsattributes_to_xmlattributes2,3},
           {exmpp_xml,unresolve_xmlel_nss,3},
           {exmpp_xml,node_to_iolist2,4},
           {exmpp_xml,node_to_binary,3},
           {exmpp_socket,send,2},
           {exmpp_session,send_packet,3},
           {exmpp_session,logged_in,3}]}

谢谢你。

4

1 回答 1

1

该错误是因为有人在原子('to')上调用 binary_to_list/1 。

最有可能的问题是“name = to”。也许它应该是二进制<<"to">>,列表"to",或者甚至是变量To(如果存在的话)。

于 2011-05-19T17:55:58.583 回答