///
import { EventEmitter } from 'events';
import { PeripheralDeviceCategory, PeripheralDeviceStatusObject, PeripheralDeviceType } from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI';
import { PeripheralDeviceAPIMethods } from '@sofie-automation/shared-lib/dist/peripheralDevice/methodsAPI';
import { DDPConnector } from './ddpConnector';
import { DDPConnectorOptions, Observer } from './ddpClient';
import { DeviceConfigManifest } from './configManifest';
import { PeripheralDeviceId } from '@sofie-automation/shared-lib/dist/core/model/Ids';
import { ExternalPeripheralDeviceAPI } from './methods';
import { PeripheralDeviceForDevice } from '@sofie-automation/shared-lib/dist/core/model/peripheralDevice';
import { ProtectedString } from '@sofie-automation/shared-lib/dist/lib/protectedString';
import { ChildCoreOptions, CoreConnectionChild } from './CoreConnectionChild';
import { ParametersOfFunctionOrNever, SubscriptionId } from './subscriptions';
import { PeripheralDevicePubSubCollections, PeripheralDevicePubSubTypes } from '@sofie-automation/shared-lib/dist/pubsub/peripheralDevice';
export interface CoreCredentials {
deviceId: PeripheralDeviceId;
deviceToken: string;
}
export interface CoreOptions extends CoreCredentials {
/**
* Category of the Device
*/
deviceCategory: PeripheralDeviceCategory;
/**
* Type of the Device
*/
deviceType: PeripheralDeviceType;
/**
* Name of the device
* eg 'MOS Gateway'
*/
deviceName: string;
/**
* URL of documentation for this Device
*/
documentationUrl: string;
versions: {
[libraryName: string]: string;
};
watchDog?: boolean;
configManifest: DeviceConfigManifest;
}
export type CollectionDocCheck = Doc extends {
_id: ProtectedString | string;
} ? Doc : never;
export interface Collection | string;
}> {
find: (selector?: any) => Array;
findOne: (docId: DBObj['_id']) => DBObj | undefined;
}
export type CoreConnectionEvents = {
connected: [];
connectionChanged: [connected: boolean];
disconnected: [];
failed: [err: Error];
error: [err: Error | string];
};
export declare class CoreConnection extends EventEmitter {
private _ddp;
private _methodQueue;
private _subscriptions;
private _children;
private _coreOptions;
private _timeSync;
private _watchDog?;
private _watchDogPingResponse;
private _connected;
private _sentConnectionId;
private _pinger;
private _destroyed;
private _peripheralDeviceApi;
private _peripheralDeviceApiLowPriority;
constructor(coreOptions: CoreOptions);
init(ddpOptions0?: DDPConnectorOptions): Promise;
destroy(): Promise;
createChild(coreOptions: ChildCoreOptions): Promise>;
removeChild(childToRemove: CoreConnectionChild): void;
onConnectionChanged(cb: (connected: boolean) => void): void;
onConnected(cb: () => void): void;
onDisconnected(cb: () => void): void;
onError(cb: (err: Error | string) => void): void;
onFailed(cb: (err: Error) => void): void;
get ddp(): DDPConnector;
get connected(): boolean;
get deviceId(): PeripheralDeviceId;
get coreMethods(): ExternalPeripheralDeviceAPI;
get coreMethodsLowPriority(): ExternalPeripheralDeviceAPI;
setStatus(status: PeripheralDeviceStatusObject): Promise;
/**
* This should not be used directly, use the `coreMethods` wrapper instead.
* Call a meteor method
* @param methodName The name of the method to call
* @param attrs Parameters to the method
* @returns Resopnse, if any
*/
callMethodRaw(methodName: string, attrs: Array): Promise;
callMethodLowPrioRaw(methodName: PeripheralDeviceAPIMethods | string, attrs: Array): Promise;
unInitialize(): Promise;
getPeripheralDevice(): Promise;
getCollection(collectionName: K): Collection>;
/**
* Subscribe to a DDP publication
* Upon reconnecting to Sofie, this publication will be restarted
*/
autoSubscribe(publicationName: Key, ...params: ParametersOfFunctionOrNever): Promise;
/**
* Unsubscribe from subscroption to a DDP publication
*/
unsubscribe(subscriptionId: SubscriptionId): void;
/**
* Unsubscribe from all subscriptions to DDP publications
*/
unsubscribeAll(): void;
observe(collectionName: K): Observer>;
getCurrentTime(): number;
hasSyncedTime(): boolean;
syncTimeQuality(): number | null;
setPingResponse(message: string): void;
private _emitError;
private _setConnected;
private _maybeSendInit;
private _sendInit;
private _watchDogCheck;
}
//# sourceMappingURL=coreConnection.d.ts.map