Swiftpack.co -  hummingbird-project/hummingbird-websocket as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
hummingbird-project/hummingbird-websocket
Websocket upgrade support for Hummingbird
.package(url: "https://github.com/hummingbird-project/hummingbird-websocket.git", from: "0.3.1")

Hummingbird Websocket

Adds support for upgrading HTTP connections to WebSocket.

Usage

let app = HBApplication()
// add HTTP to WebSocket upgrade
app.ws.addUpgrade()
// 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
        ws.write(data)
    }
}
app.start()
app.wait()

Documentation

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

GitHub

link
Stars: 6
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

v0.3.1
11 weeks ago
  • Add iOS and tvOS platform requirements
  • CI now uses swift 5.4

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