正在显示
1 个修改的文件
包含
36 行增加
和
15 行删除
| @@ -3,7 +3,11 @@ const recordInfo =require( '../../../model/RecordInfoModel'); | @@ -3,7 +3,11 @@ 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'); | ||
| 6 | 7 | ||
| 8 | +const ws = new WebSocket('ws://115.29.208.81:5000', { | ||
| 9 | + perMessageDeflate: false | ||
| 10 | +}); | ||
| 7 | 11 | ||
| 8 | function shell(){ | 12 | function shell(){ |
| 9 | 13 | ||
| @@ -11,24 +15,40 @@ function shell(){ | @@ -11,24 +15,40 @@ function shell(){ | ||
| 11 | 15 | ||
| 12 | shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ | 16 | shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ |
| 13 | // return new Promise((resolve, reject) =>{ | 17 | // return new Promise((resolve, reject) =>{ |
| 18 | + | ||
| 14 | try { | 19 | try { |
| 15 | body.id = uuid.db32() | 20 | body.id = uuid.db32() |
| 16 | body.createTime = new Date().getTime(); | 21 | body.createTime = new Date().getTime(); |
| 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 ; | 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 | ||
| 26 | } | 29 | } |
| 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}); | 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 | + | ||
| 31 | } | 38 | } |
| 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 | + // } | ||
| 32 | let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+ | 52 | let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+ |
| 33 | ` --appId ` +appId + | 53 | ` --appId ` +appId + |
| 34 | //` --uid ` +uid + | 54 | //` --uid ` +uid + |
| @@ -36,11 +56,12 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ | @@ -36,11 +56,12 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ | ||
| 36 | //`--recordFileRootDir /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples ` + | 56 | //`--recordFileRootDir /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples ` + |
| 37 | //` --channelKey ` + channelKey + | 57 | //` --channelKey ` + channelKey + |
| 38 | " --appliteDir \`pwd\`/../bin"; | 58 | " --appliteDir \`pwd\`/../bin"; |
| 39 | - console.log(shell) | 59 | + // console.log(shell) |
| 40 | 60 | ||
| 41 | - await callfile.exec(shell) | 61 | + // await callfile.exec(shell) |
| 42 | return true | 62 | return true |
| 43 | } catch (error) { | 63 | } catch (error) { |
| 64 | + | ||
| 44 | throw error | 65 | throw error |
| 45 | } | 66 | } |
| 46 | 67 |
-
请 注册 或 登录 后发表评论