25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-03 14:45:16 +02:00
xmpp.chapril.org-ejabberd/src/ejabberd_local.erl

46 lines
957 B
Erlang
Raw Normal View History

%%%----------------------------------------------------------------------
%%% File : ejabberd_local.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Created : 30 Nov 2002 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(ejabberd_local).
-author('alexey@sevcom.net').
-vsn('$Revision$ ').
%%-export([Function/Arity, ...]).
-export([start/0,init/0]).
-include("ejabberd.hrl").
start() ->
spawn(ejabberd_local, init, []).
init() ->
ejabberd_router:register_local_route(?MYNAME),
loop().
loop() ->
receive
{route, From, To, Packet} ->
do_route(From, To, Packet),
loop()
end.
do_route(From, To, Packet) ->
?DEBUG("local route~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
[From, To, Packet, 8]),
case To of
{"", _, _} ->
ok;
_ ->
ejabberd_sm ! {route, From, To, Packet}
end,
ok.