Skip to content

Commit e85ba3f

Browse files
authored
Merge pull request #17 from joshkel/docs-and-comments
Docs and comments
2 parents 1db3587 + 6fd7349 commit e85ba3f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const WebSocket = require("ws")
4646
await server.register(HAPIWebSocket)
4747
await server.register(HAPIAuthBasic)
4848

49-
/* register Basic authentication stategy */
49+
/* register Basic authentication strategy */
5050
server.auth.strategy("basic", "basic", {
5151
validate: async (request, username, password, h) => {
5252
let isValid = false
@@ -105,7 +105,7 @@ const WebSocket = require("ws")
105105
websocket: {
106106
only: true,
107107
initially: true,
108-
subprotocol: "quux",
108+
subprotocol: "quux.example.com",
109109
connect: ({ ctx, ws }) => {
110110
ctx.to = setInterval(() => {
111111
if (ws.readyState === WebSocket.OPEN)
@@ -210,7 +210,7 @@ $ wscat --connect ws://127.0.0.1:12345/baz
210210
< {"at":"baz","seen":{"foo":7}}
211211

212212
# access the full-featured exclusive WebSocket route via WebSockets
213-
$ wscat --subprotocol "quux/1.0" --auth foo:bar --connect ws://127.0.0.1:12345/quux
213+
$ wscat --subprotocol "quux.example.com" --auth foo:bar --connect ws://127.0.0.1:12345/quux
214214
< {"cmd":"HELLO",arg:"foo"}
215215
> {"cmd":"PING"}
216216
< {"result":"PONG"}
@@ -281,7 +281,7 @@ server.route({
281281
websocket: {
282282
only: true,
283283
autoping: 10 * 1000,
284-
subprotocol: "foo/1.0",
284+
subprotocol: "quux.example.com",
285285
initially: true,
286286
connect: ({ ctx, wss, ws, req, peers }) => {
287287
...

hapi-plugin-websocket.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const register = async (server, pluginOptions) => {
132132
/* establish a WebSocket server and attach it to the
133133
Node HTTP server underlying the HAPI server */
134134
wss = new WS.Server({
135-
/* the underyling HTTP server */
135+
/* the underlying HTTP server */
136136
server: server.listener,
137137

138138
/* disable per-server client tracking, as we have to perform it per-route */
@@ -238,7 +238,7 @@ const register = async (server, pluginOptions) => {
238238
/* any HTTP redirection, client error or server error response
239239
leads to an immediate WebSocket connection drop */
240240
if (response.statusCode >= 300) {
241-
const annotation = `(HAPI handler reponded with HTTP status ${response.statusCode})`
241+
const annotation = `(HAPI handler responded with HTTP status ${response.statusCode})`
242242
if (response.statusCode < 400)
243243
ws.close(1002, `Protocol Error ${annotation}`)
244244
else if (response.statusCode < 500)
@@ -292,7 +292,7 @@ const register = async (server, pluginOptions) => {
292292
})
293293
}
294294
else {
295-
/* plain WebSocket communication (uncorrelated request/reponse) */
295+
/* plain WebSocket communication (uncorrelated request/response) */
296296
ws.on("message", async (message) => {
297297
/* inject incoming WebSocket message as a simulated HTTP request */
298298
const response = await server.inject({

sample-server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const WebSocket = require("ws")
1313
await server.register(HAPIWebSocket)
1414
await server.register(HAPIAuthBasic)
1515

16-
/* register Basic authentication stategy */
16+
/* register Basic authentication strategy */
1717
server.auth.strategy("basic", "basic", {
1818
validate: async (request, username, password, h) => {
1919
let isValid = false
@@ -72,7 +72,7 @@ const WebSocket = require("ws")
7272
websocket: {
7373
only: true,
7474
initially: true,
75-
subprotocol: "quux",
75+
subprotocol: "quux.example.com",
7676
connect: ({ ctx, ws }) => {
7777
ctx.to = setInterval(() => {
7878
if (ws.readyState === WebSocket.OPEN)

0 commit comments

Comments
 (0)