Skip to content

swift-libp2p/swift-libp2p-mplex

Repository files navigation

LibP2PMPLEX

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

A LibP2P Stream Multiplexer protocol

Table of Contents

Overview

Mplex is a Stream Multiplexer protocol. The origins of this protocol are based in multiplex, the JavaScript-only Stream Multiplexer.

Mplex is a very simple protocol that does not provide many features offered by other stream multiplexers. Notably, mplex does not provide backpressure at the protocol level.

Note:

Install

Include the following dependency in your Package.swift file

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

Usage

Example

import LibP2PMPLEX

/// Tell libp2p that it can use mplex...
app.muxers.use( .mplex )

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

This repo is just a gnarly fork of the beautiful http2 code by the swift nio team below...

License

MIT © 2022 Breth Inc.