shrub/pkg/arvo/app/aqua-ames.hoon

106 lines
2.5 KiB
Plaintext
Raw Normal View History

2019-03-07 10:31:14 +03:00
:: This needs a better SDN solution. Every ship should have an IP
:: address, and we should eventually test changing those IP
:: addresses.
::
:: For now, we broadcast every packet to every ship and rely on them
:: to drop them.
::
/- aquarium
=, aquarium
2019-03-30 01:39:01 +03:00
=> |%
2019-03-07 10:31:14 +03:00
+$ move (pair bone card)
+$ card
$% [%poke wire dock %aqua-events (list aqua-event)]
[%peer wire dock path]
[%pull wire dock ~]
==
::
+$ state
$: %0
subscribed=_|
==
--
=, gall
=| moves=(list move)
2019-03-13 14:50:56 +03:00
=| aqua-event-list=(list aqua-event)
=| ships=(list ship)
2019-03-07 10:31:14 +03:00
|_ $: bowl
state
==
++ this .
2019-03-13 14:50:56 +03:00
++ apex %_(this moves ~, aqua-event-list ~, ships ~)
++ abet
=? this !=(~ aqua-event-list)
%- emit-moves
[ost %poke /aqua-events [our %aqua] %aqua-events aqua-event-list]~
:: ~? !?=(~ moves) [%aqua-ames-moves (lent moves)]
[moves this]
::
2019-03-07 10:31:14 +03:00
++ emit-moves
|= ms=(list move)
2019-03-13 14:50:56 +03:00
%_(this moves (weld moves ms))
2019-03-07 10:31:14 +03:00
::
++ emit-aqua-events
|= aes=(list aqua-event)
2019-03-13 14:50:56 +03:00
%_(this aqua-event-list (weld aqua-event-list aes))
2019-03-07 10:31:14 +03:00
::
++ poke-aqua-vane-control
|= command=?(%subscribe %unsubscribe)
2019-03-08 08:15:42 +03:00
:_ this(subscribed =(command %subscribe))
(aqua-vane-control-handler our ost subscribed command)
2019-03-07 10:31:14 +03:00
::
2019-03-30 01:39:01 +03:00
:: Handle effects from ships. We only react to %send effects.
::
2019-03-07 10:31:14 +03:00
++ diff-aqua-effects
|= [way=wire afs=aqua-effects]
^- (quip move _this)
=. this apex =< abet
|- ^+ this
?~ ufs.afs
this
=. this
?+ -.q.i.ufs.afs this
2019-03-08 08:15:42 +03:00
%restore (handle-restore who.afs)
2019-08-16 11:37:20 +03:00
%send (handle-send who.afs i.ufs.afs)
2019-03-08 08:15:42 +03:00
==
2019-03-07 10:31:14 +03:00
$(ufs.afs t.ufs.afs)
::
++ handle-restore
2019-03-08 08:15:42 +03:00
|= who=@p
2019-03-07 10:31:14 +03:00
%- emit-aqua-events
2019-08-02 02:27:33 +03:00
[%event who [//newt/0v1n.2m9vh %born ~]]~
2019-03-07 10:31:14 +03:00
::
++ handle-send
2019-08-16 11:37:20 +03:00
|= [sndr=ship way=wire %send lan=lane:ames pac=@]
2019-03-07 10:31:14 +03:00
^+ this
2019-08-16 11:37:20 +03:00
=/ rcvr=ship (lane-to-ship lan)
=/ hear-lane (ship-to-lane sndr)
2019-11-15 03:10:48 +03:00
:: => ?. ?| =(rcvr ~linnup-torsyx-linnup-torsyx)
:: =(sndr ~linnup-torsyx-linnup-torsyx)
:: ==
:: .
:: ~> %slog.0^leaf/"aqua: {(scow %p sndr)} -> {(scow %p rcvr)}"
:: .
2019-03-13 14:50:56 +03:00
%- emit-aqua-events
2019-08-16 11:37:20 +03:00
[%event rcvr //newt/0v1n.2m9vh %hear hear-lane pac]~
:: +lane-to-ship: decode a ship from an aqua lane
::
++ lane-to-ship
|= =lane:ames
^- ship
::
?- -.lane
%& p.lane
%| `ship``@`p.lane
==
:: +ship-to-lane: encode a lane to look like it came from .ship
::
:: Never shows up as a galaxy, because Vere wouldn't know that either.
::
++ ship-to-lane
|= =ship
^- lane:ames
::
[%| `address:ames``@`ship]
2019-03-07 10:31:14 +03:00
--