|
@@ -11,21 +11,41 @@ export class TestSocketIoClient {
|
|
this.socket.disconnect();
|
|
this.socket.disconnect();
|
|
}
|
|
}
|
|
|
|
|
|
- connect(url) {
|
|
|
|
- this.responses = new Subject()
|
|
|
|
|
|
+ async connect(url, options = {} ) {
|
|
|
|
+ const self = this;
|
|
|
|
+ return new Promise((resolve, reject) =>{
|
|
|
|
+ this.responses = new Subject()
|
|
|
|
+
|
|
|
|
+ const ws = io.connect(url, options)
|
|
|
|
+
|
|
|
|
+ // ws.on('connecting', (x) => { console.info('connecting', x); });
|
|
|
|
+ // ws.on('connect_failed', (x) => { console.info('connect_failed',x); });
|
|
|
|
+ // ws.on('error', (x) => { console.info('error', x); });
|
|
|
|
+ // ws.on('disconnect', (x) => { console.info('disconnect',x); });
|
|
|
|
|
|
- const ws = io.connect(url)
|
|
|
|
|
|
+ // https://socket.io/docs/v2/client-api/#Event-%E2%80%98connect-error%E2%80%99
|
|
|
|
+
|
|
|
|
+ // ws.on('pong', (x) => { console.info('pong',x); });
|
|
|
|
+ // ws.on('ping', (x) => { console.info('ping',x); });
|
|
|
|
+ // ws.on('reconnect_failed', (x) => { console.info('reconnect_failed', x); });
|
|
|
|
+ // ws.on('reconnecting', (x) => { console.info('reconnecting', x); });
|
|
|
|
+ // ws.on('reconnect_attempt', (x) => { console.info('reconnect_attempt', x); });
|
|
|
|
+ // ws.on('reconnect', (x) => { console.info('reconnect', x); });
|
|
|
|
+ // ws.on('connect_timeout', (x) => { console.info('connect_timeout',x); });
|
|
|
|
+ ws.on('connect_error', (x) => {
|
|
|
|
+ console.info('connect_error',x);
|
|
|
|
+ reject(x)
|
|
|
|
+ });
|
|
|
|
|
|
- ws.on('connecting', (x) => { console.info('connecting', x); });
|
|
|
|
- ws.on('reconnecting', (x) => { console.info('reconnecting', x); });
|
|
|
|
- ws.on('connect_failed', (x) => { console.info('connect_failed',x); });
|
|
|
|
- ws.on('error', (x) => { console.info('error', x); });
|
|
|
|
- ws.on('disconnect', (x) => { console.info('disconnect',x); });
|
|
|
|
- ws.on('connect', (x) => { console.info('connect', x) });
|
|
|
|
-
|
|
|
|
- ws.on('response', (data) => { this.responses.next(data) });
|
|
|
|
-
|
|
|
|
- this.socket = ws;
|
|
|
|
|
|
+ ws.on('connect', (x) => {
|
|
|
|
+ console.info('connect', ws.id)
|
|
|
|
+ this.socket = ws;
|
|
|
|
+ resolve(ws.id)
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ ws.on('response', (data) => { this.responses.next(data) });
|
|
|
|
+
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
getStreamOfResponsesFromRequest(request) {
|
|
getStreamOfResponsesFromRequest(request) {
|