Coder Social home page Coder Social logo

connectkit's Introduction

ConnectKit

A Swift client for Infinite Flight's Connect APIs, built using the Network framework.

Supported APIs

  • IF Session Discovery
  • Connect API V2
  • OpenTrack
  • ForeFlight

Supported targets

MacOS Mac Catalyst iOS tvOS
10.14 13 12 12

Package structure:

Module Prefix Description
ConnectV2 C2 Client for Connect V2 API
OpenTrack OT Client for sending OpenTrack broadcasts
ForeFlight FF Client for listening to ForeFlight broadcasts
ConnectKit -- Imports all of the modules above

Along with that, all packages include common components, prefixed with IF, such as IFListener used for discovering Infinite Flight sessions. If, for some reason, you want to specifically import only that functionality, you can import _ConnectKitCommon.

Getting started

Installation

if you're using XCode 11+, you can add ConnectKit as a dependency by clicking File -> Swift Packages -> Add Package Dependency and entering https://github.com/sqeezelemon/ConnectKit.git.

Alternatively, you can add it to your Package.swift file as follows:

dependencies: [
    // Add to your dependencies
    .package(url: "https://github.com/sqeezelemon/ConnectKit.git", from: "1.0.0")
]
...
.target(name: "YourTarget", dependencies: [
    // And then add to your target
    .product(name: "ConnectKit", package: "SwiftyLiveApi")
],

Discovering sessions

// 1. Create the listener
let listener = IFListener()

// 2. Add a sessionHandler
listener.sessionHandler = { (session) in 
    print($0.ipv4) // IFSession.ipv4
    listener.stop()
}

// 3. Start the listener
listener.start()

Using Connect V2 API

import ConnectV2 // or ConnectKit

// 1. Create the client
let client = C2Client()

// 2. Implement a delegate to receive data
class MyDelegate: C2ClientDelegate { ... }
let delegate = MyDelegate(...)
client.delegate = delegate

// 3. Connect to an Infinite Flight session
client.connect(to: ip)

// 4. Start using
if let id = client.findState(by: "aircraft/0/altitude_agl")?.id {
    client.get(50)
}

// 5. When finished, disconnect from IF.
client.disconnect()

Sending OpenTrack broadcasts

import OpenTrack // or ConnectKit

// 1. Create the client
let client = OTClient()

// 2. Connect to an Infinite Flight session
client.connect(to: ip)

// 3. Start using
client.send(x: x, y: y, z: z,
            roll: roll, pitch: pitch, yaw: yaw)

// 4. When finished, disconnect from IF.
client.disconnect()

Listening to ForeFlight broadcasts

import ForeFlight // or ConnectKit

// 1. Create the client
let listener = FFListener()

// 2. Implement a delegate to receive data
class MyDelegate: FFListenerDelegate { ... }
let delegate = MyDelegate(...)
listener.delegate = delegate

// 3. Start listening to broadcasts
listener.start()

// 4. When finished, stop the client.
listener.stop()

Bugs and enhancements

If you encounter a bug, please file an issue with the reproduction steps and any other information you consider helpful. If you want to suggest a change to the package, please make an issue with your proposal.

Contacts

@sqeezelemon on IFC

connectkit's People

Contributors

sqeezelemon avatar

Stargazers

 avatar  avatar  avatar  avatar  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.