liuyu 4 年之前
父节点
当前提交
f8553acfc8
共有 2 个文件被更改,包括 10 次插入0 次删除
  1. 8 0
      app/controller/home.js
  2. 2 0
      app/router.js

+ 8 - 0
app/controller/home.js

@@ -7,6 +7,14 @@ class HomeController extends Controller {
     const { ctx } = this;
     const { ctx } = this;
     ctx.body = 'hi, egg';
     ctx.body = 'hi, egg';
   }
   }
+
+  async exitroom() {
+    const { ctx } = this;
+    const { uid, roomid } = this.ctx.query;
+    const newdata = { uid, roomid };
+    this.ctx.socket.emit('message', JSON.stringify(newdata));
+    ctx.body = 'hi, egg';
+  }
 }
 }
 
 
 module.exports = HomeController;
 module.exports = HomeController;

+ 2 - 0
app/router.js

@@ -6,6 +6,8 @@
 module.exports = app => {
 module.exports = app => {
   const { router, controller, io } = app;
   const { router, controller, io } = app;
   router.get('/', controller.home.index);
   router.get('/', controller.home.index);
+  router.get('/api/stomp/exitroom', controller.home.exitroom);
+
 
 
   io.of('/').route('chat', io.controller.chat.index);
   io.of('/').route('chat', io.controller.chat.index);
   io.of('/').route('message', io.controller.chat.message);
   io.of('/').route('message', io.controller.chat.message);