Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: provide WebSocket support via http4s #187

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kubukoz
Copy link
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