2003-01-15 20:54:44 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% File : mod_echo.erl
|
|
|
|
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
|
|
|
%%% Purpose :
|
|
|
|
%%% Created : 15 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
|
|
|
|
%%% Id : $Id$
|
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
|
|
|
|
-module(mod_echo).
|
|
|
|
-author('alexey@sevcom.net').
|
|
|
|
-vsn('$Revision$ ').
|
|
|
|
|
2003-01-24 21:18:33 +01:00
|
|
|
-behaviour(gen_mod).
|
|
|
|
|
2003-01-28 20:45:13 +01:00
|
|
|
-export([start/1, init/1, stop/0]).
|
2003-01-15 20:54:44 +01:00
|
|
|
|
|
|
|
-include("ejabberd.hrl").
|
2003-03-09 21:46:47 +01:00
|
|
|
-include("jlib.hrl").
|
2003-01-15 20:54:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2003-01-24 21:18:33 +01:00
|
|
|
start(Opts) ->
|
|
|
|
%Host = gen_mod:get_opt(host, Opts),
|
|
|
|
Host = gen_mod:get_opt(host, Opts, "echo." ++ ?MYNAME),
|
2003-01-28 20:45:13 +01:00
|
|
|
register(ejabberd_mod_echo, spawn(?MODULE, init, [Host])).
|
2003-01-15 20:54:44 +01:00
|
|
|
|
2003-01-24 21:18:33 +01:00
|
|
|
init(Host) ->
|
2003-12-14 21:51:01 +01:00
|
|
|
ejabberd_router:register_route(Host),
|
2003-01-28 20:45:13 +01:00
|
|
|
loop(Host).
|
2003-01-15 20:54:44 +01:00
|
|
|
|
2003-01-28 20:45:13 +01:00
|
|
|
loop(Host) ->
|
2003-01-15 20:54:44 +01:00
|
|
|
receive
|
|
|
|
{route, From, To, Packet} ->
|
|
|
|
ejabberd_router:route(To, From, Packet),
|
2003-01-28 20:45:13 +01:00
|
|
|
loop(Host);
|
|
|
|
stop ->
|
2003-12-14 21:51:01 +01:00
|
|
|
ejabberd_router:unregister_route(Host),
|
2003-01-28 20:45:13 +01:00
|
|
|
ok;
|
2003-01-15 20:54:44 +01:00
|
|
|
_ ->
|
2003-01-28 20:45:13 +01:00
|
|
|
loop(Host)
|
2003-01-15 20:54:44 +01:00
|
|
|
end.
|
|
|
|
|
2003-01-28 20:45:13 +01:00
|
|
|
stop() ->
|
|
|
|
ejabberd_mod_echo ! stop,
|
|
|
|
ok.
|