我愿意通过使用钩子“user_send_packet”来开发自定义模块
现在我已经从函数中删除了自定义工作并编译了代码。但是当我使用这个模块时......服务器正在崩溃并不断重新启动。我没有得到什么是错的......简化的代码如下:
-module(mod_gpcustom).
-behaviour(gen_mod).
%% API
-export([start/2, stop/1]).
-export([user_send_packet/4,
mod_opt_type/1]).
-include_lib("stdlib/include/ms_transform.hrl").
-include("jlib.hrl").
%%%===================================================================
%%% API
%%%===================================================================
start(Host, _Opts) ->
ejabberd_hooks:add(user_send_packet, Host, ?MODULE,
user_send_packet, 600),
ok.
stop(Host) ->
ejabberd_hooks:delete(user_send_packet, Host, ?MODULE,
user_send_packet, 600),
ok.
user_send_packet(Pkt, C2SState, JID, Peer) ->
LUser = JID#jid.luser,
LServer = JID#jid.lserver,
ok.
mod_opt_type(cache_life_time) ->
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(cache_size) ->
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(db_type) -> fun gen_mod:v_db/1;
mod_opt_type(default) ->
fun (always) -> always;
(never) -> never;
(roster) -> roster
end;
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(store_body_only) ->
fun (B) when is_boolean(B) -> B end;
mod_opt_type(_) ->
[cache_life_time, cache_size, db_type, default, iqdisc,
store_body_only].