mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 20:21:46 +00:00
Merge pull request #23243 from jdneo/cs/wsabort
add abort() into the websocket client
This commit is contained in:
Vendored
+6
@@ -571,6 +571,12 @@ declare class client extends events.EventEmitter {
|
||||
connect(requestUrl: url.Url, protocols?: string, origin?: string, headers?: object, extraRequestOptions?: http.RequestOptions): void;
|
||||
connect(requestUrl: string, protocols?: string, origin?: string, headers?: object, extraRequestOptions?: http.RequestOptions): void;
|
||||
|
||||
/**
|
||||
* Will cancel an in-progress connection request before either the `connect` event or the `connectFailed` event has been emitted.
|
||||
* If the `connect` or `connectFailed` event has already been emitted, calling `abort()` will do nothing.
|
||||
*/
|
||||
abort(): void;
|
||||
|
||||
// Events
|
||||
on(event: string, listener: () => void): this;
|
||||
on(event: 'connect', cb: (connection: connection) => void): this;
|
||||
|
||||
@@ -180,8 +180,18 @@ function clientTest2() {
|
||||
|
||||
}
|
||||
|
||||
function testClientAbortApi() {
|
||||
var ipArray = getLocalIpArray();
|
||||
var client = new websocket.client();
|
||||
client.connect(`ws://${ipArray[0]}:8888`, undefined, undefined, undefined, {
|
||||
localAddress: ipArray[0]
|
||||
});
|
||||
client.abort();
|
||||
}
|
||||
|
||||
{
|
||||
console.log(`websocket test start.`);
|
||||
serverTest2();
|
||||
clientTest2();
|
||||
testClientAbortApi();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user