webscoket
This commit is contained in:
parent
3c52b4ff21
commit
8926c0a316
4
index.js
4
index.js
@ -79,7 +79,7 @@ const HUB = class {
|
|||||||
const FM = new HUB()
|
const FM = new HUB()
|
||||||
|
|
||||||
// 通讯频道 Frequency Modulation
|
// 通讯频道 Frequency Modulation
|
||||||
function webscoketer(ws, req) {
|
function websocketer(ws, req) {
|
||||||
|
|
||||||
// 验证身份已经登录
|
// 验证身份已经登录
|
||||||
if (!req.session.account) return ws.close()
|
if (!req.session.account) return ws.close()
|
||||||
@ -351,7 +351,7 @@ app.use(express.urlencoded({ extended: false }))
|
|||||||
app.use(session({ secret: 'kana', name: 'sid', resave: false, saveUninitialized: false, cookie: { maxAge: 180 * 24 * 3600000 }, store: session_store }))
|
app.use(session({ secret: 'kana', name: 'sid', resave: false, saveUninitialized: false, cookie: { maxAge: 180 * 24 * 3600000 }, store: session_store }))
|
||||||
app.use('/data/file/', express.static('data/file'))
|
app.use('/data/file/', express.static('data/file'))
|
||||||
|
|
||||||
app.ws('/ws', webscoketer)
|
app.ws('/ws', websocketer)
|
||||||
app.route('/').get((req, res) => res.send(`<DOCTYPE html><p> Hello World</p>`))
|
app.route('/').get((req, res) => res.send(`<DOCTYPE html><p> Hello World</p>`))
|
||||||
app.route('/user').post(object_create)
|
app.route('/user').post(object_create)
|
||||||
app.route('/account').get(online, profile)
|
app.route('/account').get(online, profile)
|
||||||
|
Loading…
Reference in New Issue
Block a user