PageRenderTime 31ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/ucengine/src/controllers/async/uce_async.erl

http://github.com/AF83/ucengine
Erlang | 45 lines | 23 code | 5 blank | 17 comment | 0 complexity | e3581fa55a0eca30f65be910d5c239bb MD5 | raw file
  1. %%
  2. %% U.C.Engine - Unified Collaboration Engine
  3. %% Copyright (C) 2011 af83
  4. %%
  5. %% This program is free software: you can redistribute it and/or modify
  6. %% it under the terms of the GNU Affero General Public License as published by
  7. %% the Free Software Foundation, either version 3 of the License, or
  8. %% (at your option) any later version.
  9. %%
  10. %% This program is distributed in the hope that it will be useful,
  11. %% but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. %% GNU Affero General Public License for more details.
  14. %%
  15. %% You should have received a copy of the GNU Affero General Public License
  16. %% along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %%
  18. -module(uce_async).
  19. -export([listen/7, filter/2]).
  20. -include("uce.hrl").
  21. listen(Domain, Location, Search, From, Types, Parent, Timeout) ->
  22. receive
  23. {event, Event} ->
  24. case filter(Search, Event) of
  25. false ->
  26. listen(Domain, Location, Search, From, Types, Parent, Timeout);
  27. true ->
  28. {ok, Event}
  29. end;
  30. Other ->
  31. ?WARNING_MSG("unattended message ~p", [Other]),
  32. {ok, []}
  33. after
  34. Timeout ->
  35. {ok, []}
  36. end.
  37. filter("", _Event) ->
  38. true;
  39. filter(Search, #uce_event{metadata=Metadata}) ->
  40. uce_event_erlang_search:search_metadata(Metadata, Search).