home.js 560 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. class HomeController extends Controller {
  4. async index() {
  5. const { ctx } = this;
  6. ctx.body = 'hi, egg';
  7. }
  8. async exitroom() {
  9. const { ctx } = this;
  10. const { uid, roomid } = this.ctx.query;
  11. // await ctx.app.io.controller.chat.message();
  12. const newdata = { uid, roomid };
  13. ctx.app.io.of('/').emit('message', JSON.stringify(newdata));
  14. // await this.ctx.socket.emit('message', JSON.stringify(newdata));
  15. ctx.body = 'hi, egg';
  16. }
  17. }
  18. module.exports = HomeController;