Skip to content

FusionKit is a custom network framer protocol on top of tcp with a small and lightweight header.

License

Notifications You must be signed in to change notification settings

Vinz1911/FusionKit

Repository files navigation

FusionKit

FusionKit is a library which implements the Fusion Framing Protocol (FFP). The Fusion Framing Protocol (FFP) is proprietary networking protocol which uses a small and lightweight header with a performance as fast as raw tcp performance. Built directly on top of Apples Network.framework with support for plain tcp and tls encrypted connections. The implementation for the host is Fusion written in golang with awesome concurrency support to ensure maximum performance.

Overview

Swift Version License Coverage
Swift 6.0 License codecov
Swift 6.0

Installation:

Swift Packages

Swift Package Manager. Just add this repo to your project.

// ...
dependencies: [
    // Dependencies declare other packages that this package depends on.
    .package(url: "https://github.com/Vinz1911/FusionKit.git", from: .init(stringLiteral: "12.0.0")),
],
// ...

Import:

// import the Framework
import FusionKit

// create a new connection
let connection = FKConnection(host: "example.com", port: 7878)

// support for NWParameters, tls example:
let connection = FKConnection(host: "example.com", port: 7878, parameters: .tls)

// ...

State Handler:

// import the Framework
import FusionKit

// create a new connection
let connection = FKConnection(host: "example.com", port: 7878)

// state update handler
connection.stateUpdateHandler = { state in
    switch state {
    case .ready:
        // connection is ready
    case .cancelled:
        // connection is cancelled
    case .failed(let error):
        // connection failed with error
    }
}

// start connection
connection.start()

Send Messages:

// import the Framework
import FusionKit

// create a new connection
let connection = FKConnection(host: "example.com", port: 7878)

// the framework accepts generic data types
// send strings
connection.send(message: "Hello World!")

// send data
connection.send(message: Data(count: 100))

// send ping
connection.send(message: UInt16.max)

Parse Message:

// import the Framework
import FusionKit

// create a new connection
let connection = FKConnection(host: "example.com", port: 7878)

// read incoming messages and transmitted bytes count
connection.receive { message, bytes in    
    // Data Message
    if case let message as Data = message { }
    
    // String Message
    if case let message as String = message { }
    
    // UInt16 Message
    if case let message as UInt16 = message { }
    
    // Input Bytes
    if let input = bytes.input { }
    
    // Output Bytes
    if let output = bytes.output { }
}

connection.send(message: "Hello World! 👻")

Author:

👨🏼‍💻 Vinzenz Weist

About

FusionKit is a custom network framer protocol on top of tcp with a small and lightweight header.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages