sprinklers3/app/script/paho-mqtt.d.ts

78 lines
3.0 KiB
TypeScript
Raw Normal View History

2017-05-06 15:39:25 -06:00
/* tslint:disable:interface-name */
declare namespace Paho {
namespace MQTT {
2017-05-06 15:39:25 -06:00
interface MQTTError { errorCode: string; errorMessage: string; }
interface WithInvocationContext { invocationContext: object; }
interface ErrorWithInvocationContext extends MQTTError, WithInvocationContext {}
2017-05-06 15:39:25 -06:00
interface OnSubscribeSuccessParams extends WithInvocationContext { grantedQos: number; }
type OnConnectionLostHandler = (error: MQTTError) => void;
type OnMessageHandler = (message: Message) => void;
interface ConnectionOptions {
timeout?: number;
userName?: string;
password?: string;
willMessage?: Message;
keepAliveInterval?: number;
cleanSession?: boolean;
useSSL?: boolean;
invocationContext?: object;
onSuccess?: (o: WithInvocationContext) => void;
mqttVersion?: number;
onFailure?: (e: ErrorWithInvocationContext) => void;
2017-05-06 15:39:25 -06:00
hosts?: string[];
ports?: number[];
}
interface SubscribeOptions {
qos?: number;
invocationContext?: object;
onSuccess?: (o: OnSubscribeSuccessParams) => void;
onFailure?: (e: ErrorWithInvocationContext) => void;
timeout?: number;
}
interface UnsubscribeOptions {
invocationContext?: object;
onSuccess?: (o: WithInvocationContext) => void;
onFailure?: (e: ErrorWithInvocationContext) => void;
timeout?: number;
}
class Client {
2017-05-06 15:39:25 -06:00
public readonly clientId: string;
public readonly host: string;
public readonly path: string;
public readonly port: number;
public onConnectionLost: OnConnectionLostHandler;
public onMessageArrived: OnMessageHandler;
public onMessageDelivered: OnMessageHandler;
2017-05-06 15:39:25 -06:00
// tslint:disable unified-signatures
constructor(host: string, port: number, path: string, clientId: string);
constructor(host: string, port: number, clientId: string);
constructor(hostUri: string, clientId: string);
2017-05-06 15:39:25 -06:00
public connect(connectionOptions?: ConnectionOptions);
public disconnect();
2017-05-06 15:39:25 -06:00
public getTraceLog(): object[];
public startTrace();
public stopTrace();
2017-05-06 15:39:25 -06:00
public send(message: Message);
public subscribe(filter: string, subcribeOptions?: SubscribeOptions);
public unsubscribe(filter: string, unsubcribeOptions?: UnsubscribeOptions);
}
class Message {
2017-05-06 15:39:25 -06:00
public destinationName: string;
public readonly duplicate: boolean;
public readonly payloadBytes: ArrayBuffer;
public readonly payloadString: string;
public qos: number;
public retained: boolean;
2017-05-06 15:39:25 -06:00
constructor(payload: string | ArrayBuffer);
}
}
}