Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ Type: `String`

If set, allows for overriding the `WebSocket` address, which corresponds to the server address by default. Values for this option should be in a valid `{host}:{port}` format. e.g. `localhost:433`.

#### `client.protocol`
Type: `String`

If set, allows for overriding the `WebSocket` protocol scheme string, which corresponds to the server protocol scheme by default. Values for this option should be one of the following: `ws` or `wss`.

#### `client.retry`
Type: `Boolean`

Expand Down
2 changes: 1 addition & 1 deletion lib/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const run = (buildHash, options) => {
const { error, info, warn } = require('./log')();

const protocol = secure ? 'wss' : 'ws';
const socket = new ClientSocket(client, `${protocol}://${client.address || address}/wps`);
const socket = new ClientSocket(client, `${client.protocol || protocol}://${client.address || address}/wps`);

const { compilerName } = options;

Expand Down
1 change: 1 addition & 0 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = {
allowMany: boolean(),
client: partial({
address: string(),
protocol: union([literal('ws'), literal('wss')]),
retry: boolean(),
silent: boolean()
}),
Expand Down
8 changes: 7 additions & 1 deletion test/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ test('defaults', (t) => {
});

test('client', (t) => {
const result = validate({ client: { address: '0', retry: false, silent: false } });
const result = validate({ client: { address: '0', protocol: "wss", retry: false, silent: false } });
t.falsy(result.error);

const resultWs = validate({ client: { address: '0', protocol: "ws", retry: false, silent: false } });
t.falsy(resultWs.error);

const resultProtocolBad = validate({ client: { address: '0', protocol: "lala", retry: false, silent: false } });
t.truthy(resultProtocolBad.error);
});

test('error', (t) => {
Expand Down