Add UpgradeAsync example, update examples
This commit is contained in:
parent
d1a2556fba
commit
369b4a551f
6 changed files with 93 additions and 13 deletions
10
examples/Upgrade.js
vendored
10
examples/Upgrade.js
vendored
|
@ -9,17 +9,23 @@ const app = uWS./*SSL*/App({
|
|||
passphrase: '1234'
|
||||
}).ws('/*', {
|
||||
/* Options */
|
||||
compression: 0,
|
||||
compression: uWS.SHARED_COMPRESSOR,
|
||||
maxPayloadLength: 16 * 1024 * 1024,
|
||||
idleTimeout: 10,
|
||||
/* Handlers */
|
||||
upgrade: (res, req, context) => {
|
||||
console.log('An Http connection wants to become WebSocket, URL: ' + req.getUrl() + '!');
|
||||
|
||||
res.upgrade({url: req.getUrl()}, req.getHeader('sec-websocket-key'),
|
||||
/* This immediately calls open handler, you must not use res after this call */
|
||||
res.upgrade({
|
||||
url: req.getUrl()
|
||||
},
|
||||
/* Spell these correctly */
|
||||
req.getHeader('sec-websocket-key'),
|
||||
req.getHeader('sec-websocket-protocol'),
|
||||
req.getHeader('sec-websocket-extensions'),
|
||||
context);
|
||||
|
||||
},
|
||||
open: (ws) => {
|
||||
console.log('A WebSocket connected with URL: ' + ws.url);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue