WIP
This commit is contained in:
+13
-9
@@ -21,7 +21,8 @@
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
-record(s,
|
||||
{stuff = none :: none | term()}).
|
||||
{host = none :: none | {Addr :: term(), Port :: term()}, % FIXME, obvsly
|
||||
socket = none :: non | gen_tcp:socket()}).
|
||||
|
||||
|
||||
stuff(Rider) ->
|
||||
@@ -39,18 +40,21 @@ retire(Rider) ->
|
||||
ok.
|
||||
|
||||
|
||||
init(Stuff) ->
|
||||
ok = tell(info, "I have Stuff: ~p", [Stuff]),
|
||||
loop(#s{stuff = Stuff}).
|
||||
init(Host = {Addr, Port}) ->
|
||||
ok = tell(info, "Addr: ~p, Port: ~p", [Addr, Port]),
|
||||
loop(#s{host = Host}).
|
||||
|
||||
|
||||
loop(State = #s{stuff = Stuff}) ->
|
||||
loop(State = #s{host = Host, socket = Socket}) ->
|
||||
receive
|
||||
{Sender, stuff} ->
|
||||
Sender ! {stuff, Stuff},
|
||||
{tcp, Socket, Message} ->
|
||||
ok = tell(info, "Got: ~tp", [Message]),
|
||||
loop(State);
|
||||
{new, NewStuff} ->
|
||||
loop(State#s{stuff = NewStuff});
|
||||
{Sender, host} ->
|
||||
Sender ! {host, Host},
|
||||
loop(State);
|
||||
{new, NewHost} ->
|
||||
loop(State#s{host = NewHost});
|
||||
retire ->
|
||||
exit(normal)
|
||||
end.
|
||||
|
||||
@@ -308,7 +308,7 @@ do_accounts(State, Manifest) ->
|
||||
|
||||
|
||||
do_check(State = #s{rider = none}) ->
|
||||
PID = spawn_link(gd_n_rider, init, ["Something"]),
|
||||
PID = spawn_link(gd_n_rider, init, [{"localhost", 7777}]),
|
||||
do_check(State#s{rider = PID});
|
||||
do_check(State = #s{rider = PID}) ->
|
||||
Stuff = gd_n_rider:stuff(PID),
|
||||
|
||||
Reference in New Issue
Block a user