Files
Xaibatsu-Control-Panel/XIONControlPanel/Servers/ServerProtocol.swift
James Magahern 918818cd99 ServerMultiplex: Introduces a server mutiplexer
- Also moves all the existing Wemo* stuff over to support the multiplexer
- Moves MainViewController to be the owner of the multiplexer, and its delegate
2020-03-14 18:33:02 -07:00

34 lines
1.0 KiB
Swift

//
// ServerProtocol.swift
// XIONControlPanel
//
// Created by James Magahern on 3/13/20.
// Copyright © 2020 XION. All rights reserved.
//
import Foundation
protocol Server
{
var connected: Bool { get }
/// Designated initializer. Takes an API endpoint URL
init(_ url: URL)
/// Attempts to connect to the server at the specified endpoint.
func connect(_ completion: @escaping (Error?) -> Void)
/// Sets server's state as "disconnected"
func disconnect(_ completion: (Error?) -> Void)
/// Fetches a list of all currently configured devices for this server, or returns an error.
func fetchDevices(_ completion: @escaping (Result<[AnyDevice], Error>) -> Void)
/// Tells the server to set the state of a given device to the given state
func toggleDevice(_ device: AnyDevice, state: DeviceState, completion: @escaping (Error?) -> Void)
/// Returns true if this is a device this server is responsible for
func responsibleForDevice(_ device: AnyDevice) -> Bool
}