mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-26 02:32:49 +00:00
* Add type definitions for async-stream-emitter, consumable-stream, writable-consumable-stream, stream-demux, ag-channel, ag-simple-broker, ncom, async-iterable-stream * Upgrade sc-broker to 8.0 * Upgrade socketcluster-client to 15.1 * Rename definition files to match module file names The files in the module were renamed. * Move socketcluster-server to v14 folder In preparation for socketcluster-server v15, since the old version is still used by other type packages. * Update scc-broker-client to 7.0 * Add current socketcluster-server type definitions Current version is v15.0 * Move sc-broker-cluster to v6 folder In preparation for sc-broker-cluster v9, since the old version is still used by other type packages. * Add current sc-broker-cluster type definitions Current version is v9.0 * Move sc-channel to v1 folder In preparation for sc-channel v2, since the old version is still used by other type packages. * Add current sc-channel type definitions Current version is v2.0 * Include the relevant sc-broker-cluster type-definitions directly in sc-channel It can be run using older and newer version of sc-broker-cluster, which have differently versioned dependencies. * Move sc-channel tests to sc-broker-cluster In the tests we use sc-broker-cluster. If the tests are in sc-channel, they drag in all dependencies for sc-broker-cluster, including esnext.asynciterable, which we don't want. * Simplify sc-errors tests In the tests we used socketcluster-server. That dragged in all of its dependencies, including esnext.asynciterable, which we don't want. * Move sc-channel to v1 folder In preparation for sc-channel v2, since the old version is still used by other type packages.
86 lines
2.5 KiB
TypeScript
86 lines
2.5 KiB
TypeScript
import AsyncStreamEmitter = require('async-stream-emitter');
|
|
import { AGClientSocket } from 'socketcluster-client';
|
|
import { Secret } from 'jsonwebtoken';
|
|
import AGChannel = require('ag-channel');
|
|
import ConsumableStream = require('consumable-stream');
|
|
|
|
import Hasher = require('./hasher');
|
|
|
|
interface ClientPoolOptions {
|
|
clientCount?: number;
|
|
targetURI: string;
|
|
authKey?: Secret;
|
|
}
|
|
|
|
interface BrokenDownURI {
|
|
hostname: string;
|
|
port?: string;
|
|
secure?: true;
|
|
}
|
|
|
|
declare class ClientPool extends AsyncStreamEmitter<any> {
|
|
hasher: Hasher;
|
|
clientCount: number;
|
|
targetURI: string;
|
|
authKey?: Secret;
|
|
clients: AGClientSocket[];
|
|
|
|
constructor(options?: ClientPoolOptions);
|
|
|
|
emit(eventName: 'error', data: { error: Error }): void;
|
|
emit(eventName: 'subscribe', data: ClientPool.SubscribeData): void;
|
|
emit(eventName: 'subscribeFail', data: ClientPool.SubscribeFailData): void;
|
|
emit(eventName: 'publish', data: ClientPool.PublishData): void;
|
|
emit(eventName: 'publishFail', data: ClientPool.PublishFailData): void;
|
|
|
|
listener(eventName: 'error'): ConsumableStream<{ error: Error }>;
|
|
listener(eventName: 'subscribe'): ConsumableStream<ClientPool.SubscribeData>;
|
|
listener(eventName: 'subscribeFail'): ConsumableStream<ClientPool.SubscribeFailData>;
|
|
listener(eventName: 'publish'): ConsumableStream<ClientPool.PublishData>;
|
|
listener(eventName: 'publishFail'): ConsumableStream<ClientPool.PublishFailData>;
|
|
|
|
breakDownURI(uri: string): BrokenDownURI;
|
|
|
|
selectClient(key: string): AGClientSocket;
|
|
|
|
invokePublish(channelName: string, data: any): Promise<void>;
|
|
|
|
subscriptions(includePending?: boolean): string[];
|
|
|
|
subscribe(channelName: string, options?: AGClientSocket.SubscribeOptions): AGChannel<any>;
|
|
unsubscribe(channelName: string): Promise<void>;
|
|
isSubscribed(channelName: string, includePending?: boolean): boolean;
|
|
|
|
closeChannel(channelName: string): void;
|
|
|
|
destroy(): void;
|
|
}
|
|
|
|
export = ClientPool;
|
|
|
|
declare namespace ClientPool {
|
|
interface SubscribeData {
|
|
targetURI: string;
|
|
poolIndex: number;
|
|
channel: string;
|
|
}
|
|
|
|
interface SubscribeFailData extends SubscribeData {
|
|
error: Error;
|
|
}
|
|
|
|
interface PublishData {
|
|
targetURI: string;
|
|
poolIndex: number;
|
|
channel: string;
|
|
data: any;
|
|
}
|
|
|
|
interface PublishFailData {
|
|
targetURI: string;
|
|
poolIndex: number;
|
|
channel: string;
|
|
error: Error;
|
|
}
|
|
}
|