API client for a light installation at the University of Kiel written in Swift

Project Lighthouse Client for Swift

An API client for a light installation at the University of Kiel using Swift 5.5’s async/await. Runs on both Linux and macOS.

Example

// Prepare connection
let conn = Connection(authentication: Authentication(
    username: "[your username]",
    token: "[your token]"
))

// Handle incoming input events
conn.onInput { input in
    print("Got input \(input)")
}

// Connect to the lighthouse server and request events
try await conn.connect()
try await conn.requestStream()

// Repeatedly send colored displays to the lighthouse
while true {
    try await conn.send(display: Display(fill: .random()))
    try await Task.sleep(nanoseconds: 1_000_000_000)
}

Usage

First make sure to have a login at lighthouse.uni-kiel.de and to have your credentials defined as environment variables:

export LIGHTHOUSE_USERNAME=[your username]
export LIGHTHOUSE_TOKEN=[your api token]

You can now run an example with

swift run

GitHub

View Github