Skip to content

Commit 2f4f565

Browse files
committed
Expose all websocket options
Signed-off-by: Chris Bygrave <[email protected]>
1 parent bfd7b2f commit 2f4f565

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

lib/firefly.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Stream, Readable } from 'stream';
2+
import * as http from 'http';
23
import * as FormData from 'form-data';
4+
import * as WebSocket from 'ws';
35
import {
46
FireFlyStatusResponse,
57
FireFlyPrivateSendOptions,
@@ -549,7 +551,7 @@ export default class FireFly extends HttpBase {
549551
listen(
550552
subscriptions: string | string[] | FireFlySubscriptionBase,
551553
callback: FireFlyWebSocketCallback,
552-
headers?: Record<string, string>,
554+
socketOptions?: WebSocket.ClientOptions | http.ClientRequestArgs,
553555
): FireFlyWebSocket {
554556
const options: FireFlyWebSocketOptions = {
555557
host: this.options.websocket.host,
@@ -560,7 +562,7 @@ export default class FireFly extends HttpBase {
560562
autoack: false,
561563
reconnectDelay: this.options.websocket.reconnectDelay,
562564
heartbeatInterval: this.options.websocket.heartbeatInterval,
563-
headers: headers,
565+
socketOptions: socketOptions,
564566
};
565567

566568
const handler: FireFlyWebSocketCallback = (socket, event) => {

lib/interfaces.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import * as http from 'http';
12
import { AxiosRequestConfig } from 'axios';
3+
import * as WebSocket from 'ws';
24
import { operations } from './schema';
35

46
/**
@@ -61,7 +63,7 @@ export interface FireFlyWebSocketOptions {
6163
autoack: boolean;
6264
reconnectDelay: number;
6365
heartbeatInterval: number;
64-
headers?: Record<string, string>;
66+
socketOptions?: WebSocket.ClientOptions | http.ClientRequestArgs;
6567
}
6668

6769
// Namespace

lib/websocket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export class FireFlyWebSocket {
5757
? `${this.options.username}:${this.options.password}`
5858
: undefined;
5959
const socket = (this.socket = new WebSocket(url, {
60+
...this.options.socketOptions,
6061
auth,
6162
handshakeTimeout: this.options.heartbeatInterval,
62-
headers: this.options.headers,
6363
}));
6464
this.closed = false;
6565

0 commit comments

Comments
 (0)