Skip to content

Commit 8446bc9

Browse files
ArtiomLjnordberg
authored andcommitted
WebSocket Subprotocol (websockets#5)
* WebSocket subprotocol * Subprotocol help * Sort subprotocol keys * ICLIOptions fix * Update Makefile * Update Makefile * Fix IOptions
1 parent 665e565 commit 8446bc9

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Usage
1717

1818
```
1919
$ wscat -h
20-
usage: wscat [-h] [-v] [-l PORT] [-b] [-k] [-d] [address]
20+
usage: wscat [-h] [-v] [-l PORT] [-b] [-k] [-d] [-s SUBP] [address]
2121
2222
Positional arguments:
2323
address
@@ -30,6 +30,8 @@ Optional arguments:
3030
-b, --binary Use binary WebSockets.
3131
-k, --keep-open Do not close the socket after EOF.
3232
-d, --deflate Use per-message deflate.
33+
-s SUBP, --subprotocol SUBP
34+
WebSocket subprotocol
3335
3436
```
3537

src/cli.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface ICLIOptions {
1010
deflate: boolean
1111
keepOpen: boolean
1212
listen?: number
13+
subProto?: string
1314
}
1415

1516
const parser = new ArgumentParser({version, addHelp: true})
@@ -39,6 +40,13 @@ parser.addArgument(['-d', '--deflate'], {
3940
help: 'Use per-message deflate.',
4041
})
4142

43+
parser.addArgument(['-s', '--subprotocol'], {
44+
dest: 'subProto',
45+
help: 'WebSocket subprotocol',
46+
metavar: 'SUBP',
47+
type: String,
48+
})
49+
4250
parser.addArgument(['address'], {
4351
nargs: '?',
4452
type: String,
@@ -52,6 +60,7 @@ const options: any = {
5260
keepOpen: args.keepOpen,
5361
outputStream: process.stdout,
5462
perMessageDeflate: args.deflate,
63+
protocol: args.subProto,
5564
}
5665

5766
if (args.address) {

src/wscat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface IOptions {
2424
keepOpen: boolean
2525
outputStream: NodeJS.WritableStream
2626
perMessageDeflate: boolean
27+
protocol: string
2728
}
2829

2930
export interface IConnectOptions extends IOptions {

0 commit comments

Comments
 (0)