Permalink
Browse files

fix simple example

  • Loading branch information...
1 parent 967406e commit 4f32b7902387563cefd06cf4136aa43718610309 @gleber committed Dec 17, 2011
@@ -1,6 +1,8 @@
#!/bin/sh
cd ../..
-erl -pa examples/simple -pa ebin/ -pa lib/*/ebin/ -boot start_sasl \
+erl -pa examples/simple -pa ebin/ -pa lib/*/ebin/ -pa ../../ebin/ -boot start_sasl \
-s exat_app \
-http_port 7778 \
-start simple_pingagent $*
+
+ # -eval "t:t(mtp)." \
@@ -1,6 +0,0 @@
-#!/bin/sh
-cd ../..
-erl -pa examples/simple -pa ebin/ -pa lib/*/ebin/ -boot start_sasl \
- -s exat_app \
- -http_port 7779 \
- -start simple_pingeragent $*
@@ -0,0 +1,9 @@
+#!/bin/sh
+cd ../..
+erl -pa examples/simple -pa ebin/ -pa lib/*/ebin/ -pa ../../ebin/ -boot start_sasl \
+ -s exat_app \
+ -http_port 7779 \
+ -start simple_pingeragent $*
+
+ # -eval "t:t(simple_agent)." \
+ # -eval "t:t(simple_pingeragent)." \
@@ -28,7 +28,7 @@ stop() ->
% agents callback
handle_acl(#aclmessage{speechact = 'INFORM',
content = "alive"} = Msg, {_, DestAgent} = State) ->
- io:format("~p is alive!", [DestAgent]),
+ io:format("~p is alive!~n", [DestAgent]),
{noreply, State};
handle_acl(#aclmessage{} = Msg, State) ->
@@ -38,7 +38,7 @@ handle_acl(#aclmessage{} = Msg, State) ->
%% gen_server callbacks
-init(Name, DestAgent) ->
+init(Name, [DestAgent]) ->
timer:send_interval(5000, ping),
{ok, {Name, DestAgent}}.
@@ -49,15 +49,17 @@ handle_cast(_Call, State) ->
{noreply, State}.
-handle_info(ping, {Name, DestAgent} = State) ->
+handle_info(ping, {SelfName, DestAgent} = State) ->
{Ip, Port, Name} = DestAgent,
Addr = lists:flatten(io_lib:format("http://~s:~b", [Ip, Port])),
- Dest = #'agent-identifier'{name = binary_to_list(Name),
+ Dest = #'agent-identifier'{name = Name,
addresses = [Addr]},
- PingMsg = #aclmessage{sender = Name,
+ PingMsg = #aclmessage{sender = SelfName,
receiver = Dest,
content = "ping"},
- Resp = acl:query_ref(PingMsg),
+ spawn(fun() ->
+ Resp = acl:query_ref(PingMsg)
+ end),
{noreply, State};
handle_info(Msg, State) ->
View
@@ -1,5 +1,5 @@
{deps_dir, ["lib"]}.
-{sub_dirs, ["examples/simple"]}.
-
+%% {sub_dirs, ["examples/simple"]}.
+{erl_opts, [{src_dirs, ["examples/simple"]}]}.
{deps, [{misultin, "0.9-dev", {git, "https://github.com/gleber/misultin.git", "master"}}]}.

0 comments on commit 4f32b79

Please sign in to comment.