Swiftpack.co - swift-libp2p/swift-libp2p-websocket as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by swift-libp2p.
swift-libp2p/swift-libp2p-websocket 0.1.3
A WebSocket Transport Module for LibP2P Applications
⭐️ 2
🕓 1 year ago
iOS macOS
.package(url: "https://github.com/swift-libp2p/swift-libp2p-websocket.git", from: "0.1.3")

LibP2PWebSocket

Swift Package Manager compatible Build & Test (macos and linux)

A WebSocket Transport module for libp2p

Table of Contents

Overview

This repo adds support for WebSockets over HTTP1 for swift-libp2p applications. WebSockets are realtime full-duplex streams over tcp. This module doesn't support WebSocket Secure (WSS) connections. Instead it encrypts traffic using a libp2p security module such as Noise.

Install

Include the following dependency in your Package.swift file

let package = Package(
    ...
    dependencies: [
        ...
        .package(url: "https://github.com/swift-libp2p/swift-libp2p-websocket.git", .upToNextMajor(from: "0.1.0"))
    ],
        ...
        .target(
            ...
            dependencies: [
                ...
                .product(name: "LibP2PWebSocket", package: "swift-libp2p-websocket"),
            ]),
    ...
)

Usage

Example


import LibP2PWebSocket

/// Tell libp2p that it should listen for WS connections on the following ip:port...
app.servers.use( .ws(host: "127.0.0.1", port: 10000) )
/// Tell libp2p that it can dial peers using WebSockets `ws`
app.transports.use( .ws )

API

Not Applicable

Contributing

Contributions are welcomed! This code is very much a proof of concept. I can guarantee you there's a better / safer way to accomplish the same results. Any suggestions, improvements, or even just critques, are welcome!

Let's make this code better together! 🤝

Credits

License

MIT © 2022 Breth Inc.

GitHub

link
Stars: 2
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

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