diff --git a/util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil.js b/util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil.js index aba2eed..2dbfc11 100644 --- a/util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil.js +++ b/util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil.js @@ -3,11 +3,7 @@ const recordInfo =require( '../../../model/RecordInfoModel'); const recordStatus =require( '../../../model/RecordStatusModel') const uuid = require('../../UuidUtil'); const moment = require('moment') -const WebSocket = require('ws'); -const ws = new WebSocket('ws://115.29.208.81:5000', { - perMessageDeflate: false -}); function shell(){ @@ -15,40 +11,24 @@ function shell(){ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ // return new Promise((resolve, reject) =>{ - try { body.id = uuid.db32() body.createTime = new Date().getTime(); - // var channelInfo = await recordStatus.findOne({where:{channel:channel}}); - //let r = await recordInfo.create(body); - var json = { - "type":"START", - "appid":body.appId, - "channel_key":body.channelKey, - "channel":body.channel - } - if(body.status == 1){ - console.log('START',json) - ws.send(JSON.stringify(json)) - }else if(body.status == 2){ - json.type = 'STOP' - console.log('STOP',json) - ws.send(JSON.stringify(json)) - + var channelInfo = await recordStatus.findOne({where:{channel:channel}}); + let r = await recordInfo.create(body); + if(channelInfo){ + if(body.status == 2){ + var channelInfo = await recordStatus.update({status:3},{where:{channel:channel}}); + }else if(channelInfo == 3){ + var channelInfo = await recordStatus.update({status:1},{where:{channel:channel}}); + }else { + throw false ; + } + }else if(body.status == 0){ + throw false ; + }else{ + var channelInfo = await recordStatus.create({id:uuid.db32(),channel:channel,status:body.status}); } - // if(channelInfo){ - // if(body.status == 2){ - // var channelInfo = await recordStatus.update({status:3},{where:{channel:channel}}); - // }else if(channelInfo == 3){ - // var channelInfo = await recordStatus.update({status:1},{where:{channel:channel}}); - // }else { - // throw false ; - // } - // }else if(body.status == 0){ - // throw false ; - // }else{ - // var channelInfo = await recordStatus.create({id:uuid.db32(),channel:channel,status:body.status}); - // } let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+ ` --appId ` +appId + //` --uid ` +uid + @@ -56,12 +36,11 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ //`--recordFileRootDir /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples ` + //` --channelKey ` + channelKey + " --appliteDir \`pwd\`/../bin"; - // console.log(shell) + console.log(shell) - // await callfile.exec(shell) + await callfile.exec(shell) return true } catch (error) { - throw error }