Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket Subprotocol #5

Merged
merged 7 commits into from
Dec 7, 2017
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Usage

```
$ wscat -h
usage: wscat [-h] [-v] [-l PORT] [-b] [-k] [-d] [address]
usage: wscat [-h] [-v] [-l PORT] [-b] [-k] [-d] [-s SUBP] [address]

Positional arguments:
address
Expand All @@ -30,6 +30,8 @@ Optional arguments:
-b, --binary Use binary WebSockets.
-k, --keep-open Do not close the socket after EOF.
-d, --deflate Use per-message deflate.
-s SUBP, --subprotocol SUBP
WebSocket subprotocol

```

Expand Down
9 changes: 9 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface ICLIOptions {
deflate: boolean
keepOpen: boolean
listen?: number
subProto?: string
}

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

parser.addArgument(['-s', '--subprotocol'], {
dest: 'subProto',
help: 'WebSocket subprotocol',
metavar: 'SUBP',
type: String,
})

parser.addArgument(['address'], {
nargs: '?',
type: String,
Expand All @@ -52,6 +60,7 @@ const options: any = {
keepOpen: args.keepOpen,
outputStream: process.stdout,
perMessageDeflate: args.deflate,
protocol: args.subProto,
}

if (args.address) {
Expand Down
1 change: 1 addition & 0 deletions src/wscat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IOptions {
keepOpen: boolean
outputStream: NodeJS.WritableStream
perMessageDeflate: boolean
protocol: string
}

export interface IConnectOptions extends IOptions {
Expand Down