question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New method for WebSocketBuilder taking Pipe[F, WebSocketFrame, WebSocketFrame]

See original GitHub issue

What’s your opinion about another build method that looks like this:

 def build(
        pipe: Pipe[F, WebSocketFrame, WebSocketFrame]
        headers: Headers = Headers.empty,
        onNonWebSocketRequest: F[Response[F]] =
          Response[F](Status.NotImplemented).withEntity("This is a WebSocket route.").pure[F],
        onHandshakeFailure: F[Response[F]] = Response[F](Status.BadRequest)
          .withEntity("WebSocket handshake failed.").pure[F])

Similarly how it’s done in akka-http. I believe it is enough for many use cases of websockets, can simplify the code and it’s easier to reason about for these use cases.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
SystemFwcommented, May 16, 2018

I’m actually thinking that a model based on a Pipe might be cleaner than what we have now, here’s a small snippet discussing translating back and forth between the two:

case class Builder(pipe: Pipe[F, Frame, Frame])
case class Split(in: Sink[F, Frame], out: Stream[F, Frame])

def splitToBuilder(s: Split) = Builder(input =>  s.out.concurrently(input.to(s.in))
case class Builder(in: Sink[F, Frame], out: Stream[F, Frame])
case class Piped(pipe: Pipe[F, Frame, Frame])

def pipedToBuilder(p: Piped): F[Builder] = 
needs to create the queue, and also quite possibly wrap everything in Option to use `unNoneTerminate`, 
without it you get race conditions like the one in Chris example that requires `sleep`
1reaction
SystemFwcommented, May 16, 2018

From what I could get, it would be an additional builder, and yes, a Pipe from input to output

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebSocketBuilder - http4s
This method allows one to attach a message to the CloseFrame as defined by the websocket protocol.
Read more >
How to Serve Web Sockets with Http4s | Stephen's Tech Blog
You get the WebSocketBuilder by using withHttpWebSocketApp on the ServerBuilder your using. Then you can serve or receive data as FS2 Streams of ......
Read more >
softwaremill/sttp - Gitter
Hey All, I am using STTP client with ZIO. Currently using send method from sttp.client3.asynchttpclient.zio._ package to make the request. But when I...
Read more >
Unit Testing http4s router websocket endpoints - Stack Overflow
toString) }) } val fromClient: Pipe[F, WebSocketFrame, Unit] = _. ... a websocket client, but I don't know of a way to do...
Read more >
WebSocket.Builder (Java SE 11 & JDK 11 ) - Oracle Help Center
public static interface WebSocket.Builder ... The intermediate (setter-like) methods change the state of the builder and return the same builder they have ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found