1 | var express = require('express');
|
2 | var expressWs = require('..');
|
3 |
|
4 | var expressWs = expressWs(express());
|
5 | var app = expressWs.app;
|
6 |
|
7 | app.param('world', function (req, res, next, world) {
|
8 | req.world = world || 'world';
|
9 | return next();
|
10 | });
|
11 |
|
12 | app.get('/hello/:world', function(req, res, next){
|
13 | console.log('hello', req.world);
|
14 | res.end();
|
15 | next();
|
16 | });
|
17 |
|
18 | app.ws('/hello/:world', function(ws, req, next) {
|
19 | ws.on('message', function(msg) {
|
20 | console.log(msg);
|
21 | });
|
22 | console.log('socket hello', req.world);
|
23 | next();
|
24 | });
|
25 |
|
26 | app.listen(3000)
|