|
1 | 1 | import { AxiosResponse } from "axios";
|
2 | 2 | import { Channel } from "./Channel";
|
| 3 | +import axios from 'axios'; |
3 | 4 |
|
4 | 5 | export type Options = { authEndpoint: string, host: string, bearerToken: string, auth: any, debug: boolean };
|
5 | 6 |
|
@@ -28,7 +29,11 @@ export class Websocket {
|
28 | 29 | private pingInterval: NodeJS.Timeout;
|
29 | 30 |
|
30 | 31 | private connect(host: string): void {
|
31 | | - this.options.debug && console.log(LOG_PREFIX + ' Trying to connect...'); |
| 32 | + if (!host) { |
| 33 | + this.options.debug && console.error(LOG_PREFIX + `Cannont connect without host !`); |
| 34 | + return; |
| 35 | + } |
| 36 | + this.options.debug && console.log(LOG_PREFIX + `Trying to connect to ${host}...` ); |
32 | 37 |
|
33 | 38 | this.websocket = new WebSocket(host);
|
34 | 39 |
|
@@ -57,7 +62,7 @@ export class Websocket {
|
57 | 62 | this.send(message);
|
58 | 63 |
|
59 | 64 | this.buffer.splice(0, 1);
|
60 | | - }; |
| 65 | + } |
61 | 66 |
|
62 | 67 | // Register events only once connected, or they won't be registered if connection failed/lost
|
63 | 68 |
|
|
0 commit comments