Giter Site home page Giter Site logo

libwebsockets.swift's Introduction

CI Status Latest Release

๐Ÿฃ libwebsockets.swift

libwebsockets.swift is a thin Swift wrapper around libwebsockets.

This library aims to be the most performant Swift Websocket library, and hence uses swift-nio EventLoops, is thread safe by default, non-blocking and manages memory automatically.

Websocket messages can be received as either Text, Binary or Fragments to be parsed manually.

SSL (wss) support is achieved using OpenSSL bindings.

Compression (permessage-deflate) is supported with all config options.

The test suite utilizes the Autobahn test suite and passes all of the (currently) 517 test cases. With the performance tests finishing ~2-3x faster than any other Swift Websocket library as of this writing.

Version

We locked-in libwebsockets version v4.3.2..<v4.4 for libwebsockets.swift versions 0.1.0..<1.0.0. So we will essentially only apply bug fix releases of libwebsockets within the current major version of libwebsockets.swift.

Example

The Examples/ directory has some examples you can use as a base for your project.

Contributing

PRs are welcome, but please make sure to keep the feature set at a minimum. Our philosophy is to be as thin of a wrapper as practical to maintain the speed and efficiency of libwebsockets while being as user friendly for Swift developers as possible.

We want to achieve maximum configurability, to make it possible to use libwebsockets.swift in any use case, but don't want to encode all use cases into the repository.

Why?

I love Swift. But I hate the ecosystem. Swift is amazing for high performance apps, but the open source ecosystem is scarce and the only Websocket libraries out there right now are slow, feature-incomplete and lack high-throughput battle-testedness.

Building on libwebsockets, which is in use by FAANG and other Fortune 500 for years already, and building the thinnest practical wrapper on top, this library aims to make the Swift ecosystem a little bit better.

Platforms

We officially support macOS and Ubuntu (as you can see in the CI). The library was built with Swift 5.8 in mind, but Swift 5.7 is tested and works as well. That being said, all little endian Systems that support Swift 5.7+ and the below system dependencies should work fine. Just make sure to run the test suite before using it in production.

System Dependencies

An up-to-date list of system dependencies can be found in the Package.swift. The most important ones are listed below:

  • OpenSSL (Homebrew: openssl, apt: libssl-dev)
  • DBus (Homebrew: dbus, apt: libdbus-1-dev)
  • Zlib (macOS: XCode command line tools, apt: libz-dev)
  • SQlite3 (Homebrew: sqlite3, apt: libsqlite3-dev)

When building a Docker image, make sure to install those system dependencies in both the build container and the run container.

Installation

Swift Package Manager

libwebsockets.swift is compatible with Swift Package Manager (Swift 5.7 and above). Simply add it to the dependencies in your Package.swift.

dependencies: [
    .package(url: "https://github.com/koraykoska/libwebsockets.swift.git", from: "0.1.0")
]

And then add it to your target dependencies:

targets: [
    .target(
        name: "MyProject",
        dependencies: [
            .product(name: "libwebsockets", package: "libwebsockets.swift"),
        ]
    ),
    .testTarget(
        name: "MyProjectTests",
        dependencies: ["MyProject"])
]

After the installation you can import libwebsockets in your .swift files.

import libwebsockets

libwebsockets.swift's People

Contributors

koraykoska avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.