summaryrefslogtreecommitdiff
path: root/app/ted
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-31 22:59:42 +0700
committerpolwex <polwex@sortug.com>2025-10-31 22:59:42 +0700
commitf019da2e338733dd88d3a8efe60f260d74b9a7ad (patch)
treeecccfab6926dd89c3ec0597653cca6e30c62dc41 /app/ted
parent54fb3abb81621bd2a5fafbdd9b96a8be8464878e (diff)
fixes to iris request flow with threads
Diffstat (limited to 'app/ted')
-rw-r--r--app/ted/ws.hoon48
1 files changed, 23 insertions, 25 deletions
diff --git a/app/ted/ws.hoon b/app/ted/ws.hoon
index d721832..ebb7926 100644
--- a/app/ted/ws.hoon
+++ b/app/ted/ws.hoon
@@ -9,14 +9,6 @@
=/ [url=@t wev=websocket-event:eyre] !<([@t websocket-event:eyre] arg)
~& > url=url
~& > req=wev
-=/ url 'ws://localhost:8888'
-::
-::
-::
-
-
-:: ;< ~ bind:m (send-request:strandio [%'GET' 'http://localhost:8888/test' ~ ~])
-::
;< =bowl:spider bind:m get-bowl:strandio
=/ desk q.byk.bowl
=/ =task:iris [%websocket-connect desk url]
@@ -24,22 +16,28 @@
;< ~ bind:m (send-raw-card:strandio card)
;< res=(pair wire sign-arvo) bind:m take-sign-arvo:strandio
~& > res=res
-:: :: confirm connection was established
-:: ?. ?=([%iris %websocket-response id=@ud websocket-event:eyre] q.res)
-:: (strand-fail:strand %bad-sign ~)
-:: ?. ?=(%accept +>+<.q.res)
-:: (strand-fail:strand %bad-sign ~)
+:: confirm connection was established
+?. ?=([%iris %websocket-response id=@ud websocket-event:eyre] q.res)
+ (strand-fail:strand %bad-sign ~)
+~& > ted-ws-res=+>.q.res
+?. ?=(%accept +>+<.q.res)
+ (pure:m !>([%ng '']))
+ :: (strand-fail:strand %bad-sign ~)
:: :: ~& ws-handshake=[id.q.res url.q.res]
-:: :: ?. ?=([%iris %websocket-handshake id=@ud url=@t] q.res)
-:: :: (strand-fail:strand %bad-sign ~)
-:: :: ~& ws-handshake=[id.q.res url.q.res]
-:: =/ wid id.+.q.res
-:: =/ =task:iris [%websocket-event wid wev]
-:: =/ =card:agent:gall [%pass /ws-req-2 %arvo %i task]
-:: ;< ~ bind:m (send-raw-card:strandio card)
-:: ;< res=(pair wire sign-arvo) bind:m take-sign-arvo:strandio
-:: ?. ?=(%iris -.q.res)
-:: (strand-fail:strand %bad-sign ~)
-:: =/ g=gift:iris +.q.res
-(pure:m !>('done'))
+:: TODO this might fail if the subscription is not set yet
+~& >>> "sleeping"
+;< ~ bind:m (sleep:strandio ~s3)
+~& >>> "slept"
+
+=/ subwire=path /websocket-server/(scot %ud id.q.res)
+=/ =cage [%websocket-response !>(+>.q.res)]
+=/ gf=gift:agent:gall [%fact :~(subwire) cage]
+=/ =card:agent:gall [%give gf]
+~& >> ws-ted-ok-sending-msg=id.q.res
+;< ~ bind:m (send-raw-card:strandio card)
+;< res2=(pair wire sign-arvo) bind:m take-sign-arvo:strandio
+?. ?=([%iris %websocket-response id=@ud %message wm=websocket-message:eyre] q.res2)
+ (strand-fail:strand %bad-sign ~)
+=/ wm=websocket-message:eyre +>+>.q.res2
+(pure:m !>([%ok id.q.res]))