Websocket.recv.loop: def of bend-kit-websocket@0.4.0.0 Import: import bend-kit-websocket@0.4.0.0/websocket.bend as Websocket Lines 1043-1094 of bend-kit-websocket@0.4.0.0/websocket.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&start_line=1043&end_line=1094 import Base import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes def recv.loop(n: Nat, h: Step, +tls: Bool, +server: Bool, +max: U32, +closing: Bool, +ms: U32) -> IO(Conn & Result<&1, &1, U32 & String, Incoming>): match n: case 0n: recv.stuck(h, tls, server, max) case 1n+p: match h: case Parse{sock, input, partial}: recv.loop(p, Decoded{sock, partial, parse(server, max, input)}, tls, server, max, closing, ms) case Decoded{sock, partial, d}: match d: case Need{input}: do IO>: r : Socket & Result<&1, &1, U32 & String, U32 & Array> <- io.recv(tls, sock, ms) recv.loop(p, Read{r, input, partial}, tls, server, max, closing, ms) case Bad{+code, why}: recv.fail(sock, tls, server, max, (code, why)) case Got{f, rest}: recv.loop(p, Fed{sock, rest, feed(partial, f, max)}, tls, server, max, closing, ms) case Fed{sock, rest, r}: match r: case Fail{e}: recv.fail(sock, tls, server, max, e) case Done{(partial, ev)}: match ev: case More{}: recv.loop(p, Parse{sock, rest, partial}, tls, server, max, closing, ms) case Message{1, d}: recv.out(sock, tls, server, rest, partial, max, closing, Done{TextMessage{d}}) case Message{op, d}: recv.out(sock, tls, server, rest, partial, max, closing, Done{Binary{d}}) case Control{9, d}: do IO>: s : Socket & Result<&1, &1, U32 & String, Unit> <- raw(server, sock, tls, True{}, 10, d) recv.loop(p, Ponged{s, rest, partial}, tls, server, max, closing, ms) case Control{10, d}: recv.out(sock, tls, server, rest, partial, max, closing, Done{Pong{d}}) case Control{op, d}: recv.closed(close.parse(d), sock, tls, server, rest, partial, max, closing) case Read{r, input, partial}: match r: case (sock, Fail{e}): recv.out(sock, tls, server, input, partial, max, closing, Fail{e}) case (sock, Done{(0, buf)}): recv.out(sock, tls, server, input, partial, max, closing, Fail{(1006, "connection closed without a close frame")}) case (sock, Done{(+len, buf)}): recv.loop(p, Parse{sock, push(input, Bytes.Bytes{len, buf}), partial}, tls, server, max, closing, ms) case Ponged{r, input, partial}: match r: case (sock, Fail{e}): recv.out(sock, tls, server, input, partial, max, closing, Fail{e}) case (sock, Done{u}): recv.loop(p, Parse{sock, input, partial}, tls, server, max, closing, ms) Uses (30): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Socket https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Word.Con https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Word.Nil https://jend.leeeet.dev/definition.txt?path=bend-kit-bytes@0.3.3.0/bytes.bend&name=Bytes https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=Conn https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=Decode https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=Incoming https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=Msg https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=Step https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=close.parse https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=feed https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=io.recv https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=parse https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=push https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=raw https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=recv.closed https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=recv.fail https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=recv.out https://jend.leeeet.dev/definition.txt?path=bend-kit-websocket@0.4.0.0/websocket.bend&name=recv.stuck