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.
33 lines
690 B
33 lines
690 B
var https = require('https'); |
|
var fs = require('fs'); |
|
|
|
var express = require('express'); |
|
var expressWs = require('..'); |
|
|
|
var options = { |
|
key: fs.readFileSync('key.pem'), |
|
cert: fs.readFileSync('cert.pem') |
|
}; |
|
var app = express(); |
|
var server = https.createServer(options, app); |
|
var expressWs = expressWs(app, server); |
|
|
|
app.use(function (req, res, next) { |
|
console.log('middleware'); |
|
req.testing = 'testing'; |
|
return next(); |
|
}); |
|
|
|
app.get('/', function(req, res, next){ |
|
console.log('get route', req.testing); |
|
res.end(); |
|
}); |
|
|
|
app.ws('/', function(ws, req) { |
|
ws.on('message', function(msg) { |
|
console.log(msg); |
|
}); |
|
console.log('socket', req.testing); |
|
}); |
|
|
|
server.listen(3000)
|
|
|