2017-08-17 11:24:46 +08:00
|
|
|
import koaRouter from 'koa-router';
|
|
|
|
import interfaceController from './controllers/interface.js';
|
2017-08-17 15:19:47 +08:00
|
|
|
const router = koaRouter();
|
2017-08-17 11:24:46 +08:00
|
|
|
|
|
|
|
function websocket(app) {
|
|
|
|
console.log('load websocket...')
|
|
|
|
app.ws.use(function (ctx, next) {
|
|
|
|
return next(ctx);
|
|
|
|
});
|
2017-08-17 15:19:47 +08:00
|
|
|
router.get('/api/interface/solve_conflict', async function (ctx) {
|
2017-08-17 11:24:46 +08:00
|
|
|
let inst = new interfaceController(ctx);
|
|
|
|
await inst.init(ctx);
|
|
|
|
if (inst.$auth === true) {
|
|
|
|
await inst.solveConflict.call(inst, ctx);
|
|
|
|
} else {
|
|
|
|
ctx.ws.send('请登录...');
|
|
|
|
}
|
2017-08-17 15:19:47 +08:00
|
|
|
})
|
2017-08-17 11:24:46 +08:00
|
|
|
|
2017-08-17 15:19:47 +08:00
|
|
|
app.ws.use(router.routes())
|
|
|
|
app.ws.use(router.allowedMethods());
|
2017-08-17 11:24:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = websocket
|