You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
539 B
26 lines
539 B
var express = require('express'); |
|
var expressWs = require('..'); |
|
|
|
var expressWs = expressWs(express()); |
|
var app = expressWs.app; |
|
|
|
app.param('world', function (req, res, next, world) { |
|
req.world = world || 'world'; |
|
return next(); |
|
}); |
|
|
|
app.get('/hello/:world', function(req, res, next){ |
|
console.log('hello', req.world); |
|
res.end(); |
|
next(); |
|
}); |
|
|
|
app.ws('/hello/:world', function(ws, req, next) { |
|
ws.on('message', function(msg) { |
|
console.log(msg); |
|
}); |
|
console.log('socket hello', req.world); |
|
next(); |
|
}); |
|
|
|
app.listen(3000)
|
|
|