Skip to content

WIP: provide WebSocket support via http4s#187

Draft
kubukoz wants to merge 1 commit into
neandertech:mainfrom
kubukoz:http4s-websocket-handler
Draft

WIP: provide WebSocket support via http4s#187
kubukoz wants to merge 1 commit into
neandertech:mainfrom
kubukoz:http4s-websocket-handler

Conversation

@kubukoz
Copy link
Copy Markdown
Contributor

@kubukoz kubukoz commented Oct 22, 2023

At the moment, usage looks like this:

// in IOApp
override def run(
  args: List[String]
): IO[ExitCode] = {
  import com.comcast.ip4s._
  EmberServerBuilder
    .default[IO]
    .withPort(port"30000")
    .withHttpWebSocketApp { ws =>
      HttpApp.liftF {
        ws.build { in =>
          fs2
            .Stream
            .resource(mkServer)
            .flatMap {
              langoustine.http4s.WebSocketServer.make(_, bufferSize = 2048).apply(in)
            }
        }
      }
    }
    .build
    .useForever
}

def mkServer: Resource[IO, LSPBuilder[IO]]

it's much nicer if you don't have per-connection resources , I'll tell you that...

Perhaps something like a WebSocketLangoustineApp should also be provided, but I suppose people might want to have the ability to configure WebSocketBuilder2 on their own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant