Skip to content

Commit

Permalink
fix(sockets): Add transports configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar committed Jul 13, 2021
1 parent ea9442c commit 2d77f8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/socketio-client/src/TranslationsClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('TranslationsClient', () => {
} as any);

client = new TranslationsClient({
transports: ['polling'],
serverUrl: 'dummy_server_url',
authentication,
});
Expand All @@ -34,7 +35,7 @@ describe('TranslationsClient', () => {
client.on('connect', () => {});
expect(io).toBeCalledWith('dummy_server_url/translations', {
query: authentication,
transports: ['websocket'],
transports: ['polling'],
});
expect(io).toHaveBeenCalledTimes(1);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/socketio-client/src/TranslationsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import io from 'socket.io-client';

type TranslationsClientOptions = {
serverUrl: string;
transports?: ('websocket' | 'polling')[];
authentication:
| {
jwtToken: string;
Expand All @@ -26,7 +27,7 @@ export class TranslationsClient {
this._socket = io(
`${this.options.serverUrl}/${TRANSLATIONS_CHANNEL_NAME}`,
{
transports: ['websocket'],
transports: this.options.transports || ['websocket'],
query: this.options.authentication,
}
);
Expand Down

0 comments on commit 2d77f8e

Please sign in to comment.