sprinklers3/common/sprinklersRpc/SprinklersRPC.ts

32 lines
979 B
TypeScript
Raw Normal View History

2018-06-16 23:54:03 -06:00
import { ConnectionState } from "./ConnectionState";
import { SprinklersDevice } from "./SprinklersDevice";
export abstract class SprinklersRPC {
2018-09-02 02:57:55 -06:00
abstract readonly connectionState: ConnectionState;
abstract readonly connected: boolean;
2018-06-16 23:54:03 -06:00
2018-09-02 02:57:55 -06:00
abstract start(): void;
2018-09-02 02:57:55 -06:00
/**
* Acquires a reference to a device. This reference must be released by calling
* SprinklersDevice#release for every time this method was called
* @param id The id of the device
*/
acquireDevice(id: string): SprinklersDevice {
const device = this.getDevice(id);
device.acquire();
return device;
}
2018-09-02 02:57:55 -06:00
/**
* Forces a device to be released. The device will no longer be updated.
*
* This should not be used normally, instead SprinklersDevice#release should be called to manage
* each reference to a device.
* @param id The id of the device to remove
*/
abstract releaseDevice(id: string): void;
2018-09-02 02:57:55 -06:00
protected abstract getDevice(id: string): SprinklersDevice;
}