1
% Copyright 2008 Konrad-Zuse-Zentrum für Informationstechnik Berlin
3
% Licensed under the Apache License, Version 2.0 (the "License");
4
% you may not use this file except in compliance with the License.
5
% You may obtain a copy of the License at
7
% http://www.apache.org/licenses/LICENSE-2.0
9
% Unless required by applicable law or agreed to in writing, software
10
% distributed under the License is distributed on an "AS IS" BASIS,
11
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
% See the License for the specific language governing permissions and
13
% limitations under the License.
14
%%%-------------------------------------------------------------------
15
%%% File : pubsub_publish.erl
16
%%% Author : Thorsten Schuett <schuett@zib.de>
17
%%% Description : Publish function
19
%%% Created : 26 Mar 2008 by Thorsten Schuett <schuett@zib.de>
20
%%%-------------------------------------------------------------------
21
%% @author Thorsten Schuett <schuett@zib.de>
22
%% @copyright 2008 Konrad-Zuse-Zentrum für Informationstechnik Berlin
24
-module(pubsub_dir.pubsub_publish).
26
-author('schuett@zib.de').
27
-vsn('$Id: pubsub_publish.erl,v 1.1 2009/11/06 12:39:55 maria Exp $ ').
29
-export([publish/3, publish_internal/3]).
36
%%====================================================================
38
%%====================================================================
40
%% @doc publishs an event to a given url.
41
%% @spec publish(string(), string(), string()) -> ok
42
%% @todo use pool:pspawn
43
publish(URL, Topic, Content) ->
44
spawn(fun () -> pubsub_publish:publish_internal(URL, Topic, Content) end),
47
publish_internal(URL, Topic, Content) ->
48
Res = jsonrpc:call(URL, [], {call, notify, [Topic, Content]}),
49
io:format("~p ~p~n", [Res, URL]).