fix(SCServer): add missing events

This commit is contained in:
Kalvis Kalniņš
2019-01-02 12:44:35 +02:00
parent 3cd60ea66f
commit 46251ff117
+17
View File
@@ -33,6 +33,13 @@ declare class SCServer extends EventEmitter {
constructor(options?: SCServer.SCServerOptions);
on(event: "connection", listener: SCServer.connectionListenerFunction): this;
on(event: "ready", listener: () => void): this;
on(event: "error", listener: (error: Error) => void): this;
on(event: "disconnection" | "connectionAbort" | "closure", listener: SCServer.disconnectionListenerFunction): this;
on(event: "subscription", listener: SCServer.subscriptionListenerFunction): this;
on(event: "unsubscription", listener: SCServer.unsubscriptionListenerFunction): this;
on(event: "handshake", listener: SCServer.handshakeListenerFunction): this;
on(event: "badSocketAuthToken", listener: SCServer.badSocketAuthTokenListenerFunction): this;
addMiddleware(type: "handshakeWS", middlewareFn: (req: IncomingMessage, next: SCServer.nextMiddlewareFunction) => void): void;
addMiddleware(type: "handshakeSC", middlewareFn: (req: SCServer.HandshakeSCRequest, next: SCServer.nextHandshakeSCMiddlewareFunction) => void): void;
@@ -305,10 +312,20 @@ declare namespace SCServer {
data?: any;
}
interface badAuthStatus {
authError: Error;
signedAuthToken: string;
}
type nextMiddlewareFunction = (error?: true | string | Error) => void;
type nextHandshakeSCMiddlewareFunction = (error?: true | string | Error | null, statusCode?: number) => void;
type nextAuthenticateMiddlewareFunction = (error?: true | string | Error | null, isBadToken?: boolean) => void;
type connectionListenerFunction = (scSocket: SCServerSocket, serverSocketStatus: SCServerSocketStatus) => void;
type disconnectionListenerFunction = (scSocket: SCServerSocket, code: number, data: any) => void;
type subscriptionListenerFunction = (scSocket: SCServerSocket, name: string, options: {channel: string}) => void;
type unsubscriptionListenerFunction = (scSocket: SCServerSocket, name: string, channel: string) => void;
type handshakeListenerFunction = (scSocket: SCServerSocket) => void;
type badSocketAuthTokenListenerFunction = (scSocket: SCServerSocket, status: badAuthStatus) => void;
interface SCCodecEngine {
decode: (input: any) => any;