Add a few more examples
This commit is contained in:
parent
84bcf4c62f
commit
a9ec4fd476
3 changed files with 64 additions and 28 deletions
|
@ -1,5 +1,4 @@
|
|||
/* The stand-alone runtime has uWS namespace already loaded. */
|
||||
var uWS = uWS ? uWS : require('../dist/uws.js');
|
||||
/* Minimal SSL/non-SSL example */
|
||||
|
||||
const port = 9001;
|
||||
|
||||
|
@ -7,32 +6,8 @@ const app = uWS./*SSL*/App({
|
|||
key_file_name: '/home/alexhultman/key.pem',
|
||||
cert_file_name: '/home/alexhultman/cert.pem',
|
||||
passphrase: '1234'
|
||||
}).get('/static/:param', (res, req) => {
|
||||
res.end('Hello, your url is ' + req.getUrl() + ". The param1 is " + req.getParameter(0));
|
||||
}).get('/hello', (res, req) => {
|
||||
res.end('Hej, du är på url: ' + req.getUrl());
|
||||
}).post('/hello', (res, req) => {
|
||||
// todo: receive the data here!
|
||||
res.end('Thanks for the data!');
|
||||
}).ws('/*', {
|
||||
compression: 0,
|
||||
maxPayloadLength: 16 * 1024 * 1024,
|
||||
open: (ws, req) => {
|
||||
console.log(ws);
|
||||
},
|
||||
message: (ws, message, isBinary) => {
|
||||
ws.send(message, isBinary);
|
||||
|
||||
console.log('BufferedAmount is ' + ws.getBufferedAmount());
|
||||
|
||||
ws.close();
|
||||
},
|
||||
drain: (ws) => {
|
||||
console.log('WebSocket drained');
|
||||
},
|
||||
close: (ws, code, message) => {
|
||||
console.log('WebSocket closed');
|
||||
}
|
||||
}).get('/*', (res, req) => {
|
||||
res.end('Hello World!');
|
||||
}).listen(port, (token) => {
|
||||
if (token) {
|
||||
console.log('Listening to port ' + port);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue