mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Callbacks are optional.
This commit is contained in:
Vendored
+7
-7
@@ -69,9 +69,9 @@ export type mapperFunction = (keyChain: KeyChain, method: string, clientIds: num
|
||||
export class SCExchange extends AbstractDataClient {
|
||||
constructor(privateClientCluster: ClientCluster, publicClientCluster: ClientCluster, ioClusterClient: Client);
|
||||
|
||||
send(data: any, mapIndex: number | string | string[] | null, callback?: (err?: Error) => void): void;
|
||||
send(data: any, mapIndex: number | string | string[] | null, callback?: AsyncResultArrayCallback<any>): void;
|
||||
|
||||
publish(channelName: string, data: any, callback: (err?: Error) => void): void;
|
||||
publish(channelName: string, data: any, callback?: (err?: Error) => void): void;
|
||||
|
||||
subscribe(channelName: string): SCChannel;
|
||||
unsubscribe(channelName: string): void;
|
||||
@@ -146,12 +146,12 @@ export class Client extends EventEmitter {
|
||||
on(event: "ready", listener: () => void): this;
|
||||
on(event: "message", listener: (packet: MessagePacket) => void): this;
|
||||
|
||||
destroy(callback: AsyncResultArrayCallback<SCExchange>): void;
|
||||
destroy(callback?: AsyncResultArrayCallback<SCExchange>): void;
|
||||
|
||||
subscribe(channel: string, callback: (err?: Error) => void): void;
|
||||
unsubscribe(channel: string, callback: () => void): void;
|
||||
unsubscribeAll(callback: () => void): void;
|
||||
isSubscribed(channel: string, includePending: boolean): boolean;
|
||||
subscribe(channel: string, callback?: (err?: Error) => void): void;
|
||||
unsubscribe(channel: string, callback?: () => void): void;
|
||||
unsubscribeAll(callback?: AsyncResultArrayCallback<any>): void;
|
||||
isSubscribed(channel: string, includePending?: boolean): boolean;
|
||||
|
||||
subscribeSocket(socket: SCServerSocket, channel: string, callback?: (err?: Error) => void): void;
|
||||
unsubscribeSocket(socket: SCServerSocket, channel: string, callback?: () => void): void;
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Client } from "sc-broker-cluster";
|
||||
import { SCServer, SCServerSocket } from "socketcluster-server";
|
||||
import WebSocket = require("ws");
|
||||
|
||||
// Client tests
|
||||
|
||||
const client = new Client({
|
||||
brokers: [],
|
||||
secretKey: "secretKey",
|
||||
@@ -12,18 +14,47 @@ const client = new Client({
|
||||
client.on("error", err => {});
|
||||
client.on("warning", err => {});
|
||||
|
||||
const exchange = client.exchange();
|
||||
|
||||
const scServer = new SCServer();
|
||||
client.setSCServer(scServer);
|
||||
|
||||
client.once("ready", () => {});
|
||||
|
||||
client.subscribe("channel");
|
||||
client.subscribe("channel", () => {});
|
||||
client.subscribe("channel", err => {});
|
||||
|
||||
client.unsubscribe("channel");
|
||||
client.unsubscribe("channel", () => {});
|
||||
|
||||
client.unsubscribeAll();
|
||||
client.unsubscribeAll(() => {});
|
||||
client.unsubscribeAll(err => {});
|
||||
client.unsubscribeAll((err, results) => {});
|
||||
|
||||
client.isSubscribed("channel");
|
||||
client.isSubscribed("channel", true);
|
||||
|
||||
const wsSocket = new WebSocket("address");
|
||||
const socket = new SCServerSocket("id", scServer, wsSocket);
|
||||
client.subscribeSocket(socket, "channelName");
|
||||
client.subscribeSocket(socket, "channelName", err => {});
|
||||
|
||||
client.unsubscribeSocket(socket, "channelName");
|
||||
client.unsubscribeSocket(socket, "channelName", () => {});
|
||||
|
||||
const data: any = {};
|
||||
exchange.publish("channelName", data, err => {});
|
||||
client.destroy();
|
||||
client.destroy(() => {});
|
||||
client.destroy(err => {});
|
||||
client.destroy((err, results) => {});
|
||||
|
||||
// SCExchange tests
|
||||
|
||||
const exchange = client.exchange();
|
||||
|
||||
exchange.send({}, null);
|
||||
exchange.send("dummy", 1, () => {});
|
||||
exchange.send("dummy", ["1", "2"], err => {});
|
||||
exchange.send(123, "*", (err, results) => {});
|
||||
|
||||
exchange.publish("channelName", {}, err => {});
|
||||
exchange.publish("channelName", {});
|
||||
|
||||
Reference in New Issue
Block a user