Swiftpack.co - hummingbird-project/hummingbird-websocket as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by hummingbird-project.
hummingbird-project/hummingbird-websocket 1.2.0
Websocket upgrade support for Hummingbird
⭐️ 20
🕓 20 weeks ago
iOS tvOS linux macOS iOS
.package(url: "https://github.com/hummingbird-project/hummingbird-websocket.git", from: "1.2.0")

Hummingbird Websocket

Adds support for upgrading HTTP connections to WebSocket.


let app = HBApplication()
// add HTTP to WebSocket upgrade
// add middleware to websocket initial requests
app.ws.add(middleware: HBLogRequestsMiddleware(.info))
// on websocket connect. 
app.ws.on("/ws") { req, ws in
    // send ping and wait for pong and repeat every 60 seconds
    ws.initiateAutoPing(interval: .seconds(60))
    // on read from client send the same data back
    ws.onRead { data, ws in


You can find reference documentation for HummingbirdWebSocket here. The hummingbird-examples repository has a number of examples of different uses of the library.


Stars: 20
Last commit: 1 week ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

33 weeks ago

Minor version changes

  • Add support to supply additional headers during initial HTTP connection when using client. PR #20
  • Add support for editing maxFrameSize. PR #23
  • Add read callback in HBWebSocketClient. If you add a readCallback after the client has been created it is possible to miss packets. This ensures you don't miss any packets. PR #25
  • Require Hummingbird 1.4.0
  • Add public API to send an unsolicited pong message. PR #28 from @tkrajacic

Patch version changes

  • Fix the masking key generation not generating 0x0. PR #16 from @Joannis

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics