liuyu 4 år sedan
förälder
incheckning
3aef9c471c
2 ändrade filer med 36 tillägg och 0 borttagningar
  1. 35 0
      app/controller/room.js
  2. 1 0
      app/router.js

+ 35 - 0
app/controller/room.js

@@ -183,6 +183,41 @@ class RoomController extends Controller {
     this.ctx.ok({ data });
   }
 
+  // 解散房间
+  async dismissroom() {
+    // 调用解散房间接口
+    // 取得公共参数头
+    const SecretId = 'AKIDCAtWu3GhY9VbQzJgfOq4QVJq8AxWi3Sa';
+    const SecretKey = '3sRknnwoOhlY4JH2Wjf6VeYCdnhKr88z';
+    // 导入对应产品模块的client models。
+    const TrtcClient = tencentcloud.trtc.v20190722.Client;
+    const models = tencentcloud.trtc.v20190722.Models;
+
+    const Credential = tencentcloud.common.Credential;
+    const ClientProfile = tencentcloud.common.ClientProfile;
+    const HttpProfile = tencentcloud.common.HttpProfile;
+
+    const cred = new Credential(SecretId, SecretKey);
+    const httpProfile = new HttpProfile();
+    httpProfile.endpoint = 'trtc.tencentcloudapi.com';
+    const clientProfile = new ClientProfile();
+    clientProfile.httpProfile = httpProfile;
+    const client = new TrtcClient(cred, 'ap-beijing', clientProfile);
+    const req = new models.DismissRoomRequest();
+
+    const params = {};
+    params.SdkAppId = this.app.config.sdkappid;
+    params.RoomId = this.ctx.query.roomname;
+    req.from_json_string(JSON.stringify(params));
+    client.DismissRoom(req, function(errMsg, response) {
+      if (errMsg) {
+        console.log(errMsg);
+      }
+      console.log(response.to_json_string());
+    });
+    this.ctx.ok({ });
+  }
+
 }
 
 module.exports = CrudController(RoomController, meta);

+ 1 - 0
app/router.js

@@ -32,6 +32,7 @@ module.exports = app => {
   router.post('/api/onlive/room/updateshmai', controller.room.updateshmai);
   router.post('/api/onlive/room/switchzjr', controller.room.switchzjr);
   router.post('/api/onlive/room/switchzb', controller.room.switchzb);
+  router.post('/api/onlive/room/dismissroom', controller.room.dismissroom);
 
   // 聊天表设置路由
   router.resources('chat', '/api/onlive/chat', controller.chat); // index、create、show、destroy