蒋利兵

合并分支 'revert-2a1f6481' 到 'nows'

Revert "ws"

This reverts commit 2a1f6481

查看合并请求 !1
@@ -3,11 +3,7 @@ const recordInfo =require( '../../../model/RecordInfoModel'); @@ -3,11 +3,7 @@ const recordInfo =require( '../../../model/RecordInfoModel');
3 const recordStatus =require( '../../../model/RecordStatusModel') 3 const recordStatus =require( '../../../model/RecordStatusModel')
4 const uuid = require('../../UuidUtil'); 4 const uuid = require('../../UuidUtil');
5 const moment = require('moment') 5 const moment = require('moment')
6 -const WebSocket = require('ws');  
7 6
8 -const ws = new WebSocket('ws://115.29.208.81:5000', {  
9 - perMessageDeflate: false  
10 -});  
11 7
12 function shell(){ 8 function shell(){
13 9
@@ -15,40 +11,24 @@ function shell(){ @@ -15,40 +11,24 @@ function shell(){
15 11
16 shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ 12 shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{
17 // return new Promise((resolve, reject) =>{ 13 // return new Promise((resolve, reject) =>{
18 -  
19 try { 14 try {
20 body.id = uuid.db32() 15 body.id = uuid.db32()
21 body.createTime = new Date().getTime(); 16 body.createTime = new Date().getTime();
22 - // var channelInfo = await recordStatus.findOne({where:{channel:channel}});  
23 - //let r = await recordInfo.create(body);  
24 - var json = {  
25 - "type":"START",  
26 - "appid":body.appId,  
27 - "channel_key":body.channelKey,  
28 - "channel":body.channel  
29 - }  
30 - if(body.status == 1){  
31 - console.log('START',json)  
32 - ws.send(JSON.stringify(json))  
33 - }else if(body.status == 2){  
34 - json.type = 'STOP'  
35 - console.log('STOP',json)  
36 - ws.send(JSON.stringify(json))  
37 - 17 + var channelInfo = await recordStatus.findOne({where:{channel:channel}});
  18 + let r = await recordInfo.create(body);
  19 + if(channelInfo){
  20 + if(body.status == 2){
  21 + var channelInfo = await recordStatus.update({status:3},{where:{channel:channel}});
  22 + }else if(channelInfo == 3){
  23 + var channelInfo = await recordStatus.update({status:1},{where:{channel:channel}});
  24 + }else {
  25 + throw false ;
  26 + }
  27 + }else if(body.status == 0){
  28 + throw false ;
  29 + }else{
  30 + var channelInfo = await recordStatus.create({id:uuid.db32(),channel:channel,status:body.status});
38 } 31 }
39 - // if(channelInfo){  
40 - // if(body.status == 2){  
41 - // var channelInfo = await recordStatus.update({status:3},{where:{channel:channel}});  
42 - // }else if(channelInfo == 3){  
43 - // var channelInfo = await recordStatus.update({status:1},{where:{channel:channel}});  
44 - // }else {  
45 - // throw false ;  
46 - // }  
47 - // }else if(body.status == 0){  
48 - // throw false ;  
49 - // }else{  
50 - // var channelInfo = await recordStatus.create({id:uuid.db32(),channel:channel,status:body.status});  
51 - // }  
52 let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+ 32 let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+
53 ` --appId ` +appId + 33 ` --appId ` +appId +
54 //` --uid ` +uid + 34 //` --uid ` +uid +
@@ -56,12 +36,11 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ @@ -56,12 +36,11 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{
56 //`--recordFileRootDir /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples ` + 36 //`--recordFileRootDir /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples ` +
57 //` --channelKey ` + channelKey + 37 //` --channelKey ` + channelKey +
58 " --appliteDir \`pwd\`/../bin"; 38 " --appliteDir \`pwd\`/../bin";
59 - // console.log(shell) 39 + console.log(shell)
60 40
61 - // await callfile.exec(shell) 41 + await callfile.exec(shell)
62 return true 42 return true
63 } catch (error) { 43 } catch (error) {
64 -  
65 throw error 44 throw error
66 } 45 }
67 46