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