diff options
| author | polwex <polwex@sortug.com> | 2025-10-28 05:58:35 +0700 |
|---|---|---|
| committer | polwex <polwex@sortug.com> | 2025-10-28 05:58:35 +0700 |
| commit | 54fb3abb81621bd2a5fafbdd9b96a8be8464878e (patch) | |
| tree | dbc0ba869c471f8d80b73a1130a9dbd2c029dd3e | |
| parent | c61bca793741959fdcd87f70854bc75cf263495f (diff) | |
really not convinced this is the better approach
| -rw-r--r-- | arvo/eyre.hoon | 29 | ||||
| -rw-r--r-- | arvo/iris.hoon | 83 |
2 files changed, 60 insertions, 52 deletions
diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 6fcd05f..4d9e615 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -43,7 +43,7 @@ ++ axle $: :: date: date at which http-server's state was updated to this data structure :: - date=%~2025.1.31 + date=%~2025.10.28 :: server-state: state of inbound requests :: =server-state @@ -95,6 +95,8 @@ :: who may have been affected by urbit/urbit#7103 :: check-session-timer=_| + :: UIP 125 + sockets=(map @ud websocket-connection) == :: channel-request: an action requested on a channel :: @@ -3209,6 +3211,7 @@ ++ handle-ws-response |= [wid=@ event=websocket-event] ^- [(list move) server-state] + ~& eyre-handle-ws-esponse=[wid event] :: TODO remove if not accepted? =. connections.state ?. ?=(%reject -.event) connections.state @@ -4283,7 +4286,8 @@ [date=%~2023.4.11 server-state-3] [date=%~2023.5.15 server-state-4] [date=%~2024.8.20 server-state-4] - [date=%~2025.1.31 server-state] + [date=%~2025.1.31 server-state-5] + [date=%~2025.10.28 server-state] == :: +$ server-state-0 @@ -4395,6 +4399,20 @@ ports=[insecure=@ud secure=(unit @ud)] outgoing-duct=duct verb=@ + == + +$ server-state-5 + $: bindings=(list [=binding =duct =action]) + cache=(map url=@t [aeon=@ud val=(unit cache-entry)]) + =cors-registry + connections=(map duct outstanding-connection) + auth=authentication-state + =channel-state + domains=(set turf) + =http-config + ports=[insecure=@ud secure=(unit @ud)] + outgoing-duct=duct + verb=@ + check-session-timer=_| == -- |= old=axle-any @@ -4514,8 +4532,13 @@ date.old %~2025.1.31 verb.old [verb.old check-session-timer=&] == - :: %~2025.1.31 + %= $ + date.old %~2025.10.28 + check-session-timer.old [check-session-timer.old sockets=~] + == + :: + %~2025.10.28 http-server-gate(ax old) :: == diff --git a/arvo/iris.hoon b/arvo/iris.hoon index 1e8cdee..41a4160 100644 --- a/arvo/iris.hoon +++ b/arvo/iris.hoon @@ -258,6 +258,7 @@ =/ connection (~(got by connection-by-id.state) id) :: reassemble the octs that we've received into their final form :: + ~& iris-sending-finished=[id=id duct=duct connection=connection] =/ data=octs %- combine-octs %- flop @@ -312,12 +313,10 @@ ~& "cant sent second ws-connect on same duct" `state :: TODO ... the wid comes from vere tho...? =^ id next-id.state [next-id.state +(next-id.state)] + =/ wc=websocket-connection [desk duct id url %pending] =. sockets.state (~(put by sockets.state) id wc) :: :: keep track of the duct for cancellation - :: :: - :: =. connection-by-duct.state - :: (~(put by connection-by-duct.state) duct id) :: This sends it to Vere to actually do the request :- [outbound-duct.state %give %websocket-handshake id url]~ @@ -327,55 +326,38 @@ ++ ws-event |= [wid=@ud event=websocket-event:eyre] ~& iris-ws-event=[wid event duct] - =/ wc (~(got by sockets.state) wid) - ?- -.event - %accept - =. wc wc(status %accepted) - =. sockets.state (~(put by sockets.state) wid wc) - :_ state :~ (watch-agent wid app.wc) - == - %message :_ state - :~ (poke-agent [wid +.event] app.wc) - == - %reject (cleanup-ws wid) - %disconnect (cleanup-ws wid) - == - :: this API sucks but for the time being - :: route differently if from runtime (incoming) or from urbit (look at first piece of the duct) - :: ?~ duct `state - :: =/ connection (~(got by connection-by-id.state) wid) - :: =/ pol `(pole knot)`i.duct - :: :: from runtime, return to app - :: ?+ pol `state - :: [%http-client id=@t *] (ws-response wid event) - :: :: :: [%gall %use %spider *] - :: [%gall %use app=@t *] - :: :_ state - :: :: if connection accepted we subscribe to app - :: :~ [outbound-duct.state %give %websocket-response wid event] - :: :* duct.connection - :: %pass - :: /iris-ws-watch - :: %g %deal - :: [our our /iris] - :: app.pol - :: %watch /websocket-client/(scot %ud wid) - :: == - :: == - :: == + =/ wc (~(get by sockets.state) wid) + ?~ wc `state + =/ wc u.wc + ~& wc=wc + =^ moves state + ?- -.event + %accept + =. wc wc(status %accepted) + =. sockets.state (~(put by sockets.state) wid wc) + :_ state + :: :~ (watch-agent wid app.wc) + :: == + ~ + %message :_ state + :: :~ (poke-agent [wid +.event] app.wc) + :: == + ~ + %reject (cleanup-ws wid) + %disconnect (cleanup-ws wid) + == + =/ m2 (ws-response wc event) + [(welp m2 moves) state] ++ ws-response - |= [wid=@ud event=websocket-event:eyre] - =/ connection (~(got by connection-by-id.state) wid) - ~& >> connection=connection - :_ - ?: ?| ?=(%reject -.event) ?=(%disconnect -.event) == - (cleanup-connection wid) state - :~ :* duct.connection + |= [wc=websocket-connection event=websocket-event:eyre] + ~& ws-response=wc + :~ :* + duct.wc %give %websocket-response - wid + id.wc event == == @@ -550,15 +532,18 @@ ^- roon |= [lyc=gang pov=path car=term bem=beam] ^- (unit (unit cage)) + ~& >> iris-scry=[lyc=lyc pov=pov car=car bem=bem syd=q.bem] + ?. ?=(%x car) [~ ~] + ?: ?=(%ws q.bem) ``noun+!>(sockets.state.ax) =* ren car =* why=shop &/p.bem =* syd q.bem =* lot=coin $/r.bem - =* tyl s.bem + =* tyl s.bem :: ?. ?=(%& -.why) ~ =* his p.why - ?: &(?=(%x ren) =(tyl //whey) =([~ ~] lyc)) + ?: &(=(tyl //whey) =([~ ~] lyc)) =/ maz=(list mass) :~ nex+&+next-id.state.ax outbound+&+outbound-duct.state.ax |
