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

84 lines
2.0 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-03-07 10:31:14 +03:00
%send (handle-send 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
|= [way=wire %send lan=lane:ames pac=@]
^+ this
=/ hear [//newt/0v1n.2m9vh %hear lan pac]
2019-03-13 14:50:56 +03:00
=? ships =(~ ships)
2019-03-07 10:31:14 +03:00
.^((list ship) %gx /(scot %p our)/aqua/(scot %da now)/ships/noun)
2019-03-13 14:50:56 +03:00
%- emit-aqua-events
%+ turn ships
2019-03-07 10:31:14 +03:00
|= who=ship
[%event who hear]
--