From d06df75ac2fb393e239e874b5e0c7c9b180e15a2 Mon Sep 17 00:00:00 2001 From: kamek-pf Date: Mon, 10 Apr 2017 21:06:11 -0400 Subject: [PATCH] Added connexion event listener --- types/thrift/index.d.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/types/thrift/index.d.ts b/types/thrift/index.d.ts index cd11e25357..aea4bdf01a 100644 --- a/types/thrift/index.d.ts +++ b/types/thrift/index.d.ts @@ -17,7 +17,7 @@ export class TBinaryProtocol {} * Server side */ export interface ThriftServer { - listen(port: number): any; + listen(port: number): any; } export function createServer(generatedService: any, serviceMethods: any): ThriftServer; @@ -25,10 +25,16 @@ export function createServer(generatedService: any, serviceMethods: any): Thrift /** * Client side */ +export type ConnexionEvent = 'open' | 'message' | 'close' | 'error'; + export interface ClientConnectionParams { - transport: TJSONProtocol | TBinaryProtocol; - protocol: TBufferedTransport | TXHRTransport; + transport: TJSONProtocol | TBinaryProtocol; + protocol: TBufferedTransport | TXHRTransport; } -export function createConnection(host: string, port: number, params: ClientConnectionParams): {}; +export interface ClientConnection { + on(event: ConnexionEvent, callback: (...args: any[]) => void): void; +} + +export function createConnection(host: string, port: number, params: ClientConnectionParams): ClientConnection; export function createClient(generatedService: any, connection: {}): any;