This commit is contained in:
2026-05-18 21:54:46 +09:00
parent b256db6ff6
commit 7192a35d89
2 changed files with 14 additions and 10 deletions
+13 -9
View File
@@ -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.
+1 -1
View File
@@ -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),