liuyu 4 years ago
parent
commit
f8553acfc8
2 changed files with 10 additions and 0 deletions
  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;
     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;

+ 2 - 0
app/router.js

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