summaryrefslogtreecommitdiff
path: root/app/ted/ws.hoon
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-28 02:54:55 +0700
committerpolwex <polwex@sortug.com>2025-10-28 02:54:55 +0700
commitc61bca793741959fdcd87f70854bc75cf263495f (patch)
tree042f5b37f89ce82e552e70364bb708450f2cd685 /app/ted/ws.hoon
parent53ca6679beb5cc7c5d9016d0af4adc4e31ccd69d (diff)
refactor of nostrill backend to deal with websockets on Iris. almost complete
Diffstat (limited to 'app/ted/ws.hoon')
-rw-r--r--app/ted/ws.hoon43
1 files changed, 34 insertions, 9 deletions
diff --git a/app/ted/ws.hoon b/app/ted/ws.hoon
index b8dd583..d721832 100644
--- a/app/ted/ws.hoon
+++ b/app/ted/ws.hoon
@@ -1,20 +1,45 @@
-/- spider
+/- spider, nsur=nostr
/+ strandio
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
-=/ url=@t (need !<((unit @t) arg))
+:: =/ [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=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]
-=/ =card:agent:gall [%pass /ws-req %arvo %i task]
+=/ =card:agent:gall [%pass /ws-req/nostrill %arvo %i task]
;< ~ bind:m (send-raw-card:strandio card)
;< res=(pair wire sign-arvo) bind:m take-sign-arvo:strandio
-?. ?=([%iris %websocket-handshake id=@ud url=@t] q.res)
- (strand-fail:strand %bad-sign ~)
-~& ws-handshake=[id.q.res url.q.res]
-:: ?: ?=([%iris %websocket-response id=@ud e=websocket-event:eyre] q.res)
-=/ data=@t 'done'
-(pure:m !>(data))
+~& > 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 ~)
+
+:: :: ~& 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'))