summaryrefslogtreecommitdiff
path: root/app/ted/ws.hoon
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-11-01 03:55:13 +0700
committerpolwex <polwex@sortug.com>2025-11-01 03:55:13 +0700
commit7305d67ff7f9e78b73326ef0e1f68a9613d34205 (patch)
tree5e075673b42811a76963c956502ac2c5fc2ea8f4 /app/ted/ws.hoon
parentf019da2e338733dd88d3a8efe60f260d74b9a7ad (diff)
ws connection to relay fixed, tested
Diffstat (limited to 'app/ted/ws.hoon')
-rw-r--r--app/ted/ws.hoon34
1 files changed, 19 insertions, 15 deletions
diff --git a/app/ted/ws.hoon b/app/ted/ws.hoon
index ebb7926..9f9c298 100644
--- a/app/ted/ws.hoon
+++ b/app/ted/ws.hoon
@@ -6,9 +6,9 @@
=/ m (strand ,vase)
^- form:m
:: =/ [url=@t req=client-msg:nsur] (need !<((unit [@t client-msg:nsur]) arg))
-=/ [url=@t wev=websocket-event:eyre] !<([@t websocket-event:eyre] arg)
+=/ [url=@t wmsg=websocket-message:eyre] !<([@t websocket-message:eyre] arg)
~& > url=url
-~& > req=wev
+~& > req=wmsg
;< =bowl:spider bind:m get-bowl:strandio
=/ desk q.byk.bowl
=/ =task:iris [%websocket-connect desk url]
@@ -19,25 +19,29 @@
:: confirm connection was established
?. ?=([%iris %websocket-response id=@ud websocket-event:eyre] q.res)
(strand-fail:strand %bad-sign ~)
-~& > ted-ws-res=+>.q.res
+~& > ted-ws-res=+>+<.q.res
?. ?=(%accept +>+<.q.res)
(pure:m !>([%ng '']))
:: (strand-fail:strand %bad-sign ~)
-:: :: ~& ws-handshake=[id.q.res url.q.res]
-:: TODO this might fail if the subscription is not set yet
+~& "ws connection accepted, sending ws msg"
~& >>> "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)
+=/ card2=card:agent:gall
+ [%pass /ws/proxy %agent [our.bowl desk] %poke %websocket-thread !>([id.q.res wmsg])]
+;< ~ bind:m (send-raw-card:strandio card2)
;< 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
+
+
+:: =/ 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]))