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.
Swift Version | License | Coverage |
---|---|---|
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 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)
// ...
// 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()
// 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)
// 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! 👻")
👨🏼💻 Vinzenz Weist