正在显示
1 个修改的文件
包含
31 行增加
和
12 行删除
| @@ -5,9 +5,8 @@ const uuid = require('../../UuidUtil'); | @@ -5,9 +5,8 @@ const uuid = require('../../UuidUtil'); | ||
| 5 | const moment = require('moment') | 5 | const moment = require('moment') |
| 6 | const WebSocket = require('ws'); | 6 | const WebSocket = require('ws'); |
| 7 | 7 | ||
| 8 | -const ws = new WebSocket('ws://115.29.208.81:5000', { | ||
| 9 | - perMessageDeflate: false | ||
| 10 | -}); | 8 | +var ws = new WebSocket('ws://123.56.204.132:5000', { |
| 9 | + }); | ||
| 11 | 10 | ||
| 12 | function shell(){ | 11 | function shell(){ |
| 13 | 12 | ||
| @@ -27,15 +26,36 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ | @@ -27,15 +26,36 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ | ||
| 27 | "channel_key":body.channelKey, | 26 | "channel_key":body.channelKey, |
| 28 | "channel":body.channel | 27 | "channel":body.channel |
| 29 | } | 28 | } |
| 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 | - | 29 | + if(ws.readyState == 3){ |
| 30 | + ws = new WebSocket('ws://123.56.204.132:5000', { | ||
| 31 | + }); | ||
| 32 | + if(body.status == 1){ | ||
| 33 | + console.log('START',json) | ||
| 34 | + setTimeout(function() { | ||
| 35 | + console.log( ws.readyState) | ||
| 36 | + ws.send(JSON.stringify(json)) | ||
| 37 | + }, 20); | ||
| 38 | + }else if(body.status == 2){ | ||
| 39 | + json.type = 'STOP' | ||
| 40 | + setTimeout(function() { | ||
| 41 | + console.log( ws.readyState) | ||
| 42 | + ws.send(JSON.stringify(json)) | ||
| 43 | + }, 20); | ||
| 44 | + } | ||
| 45 | + }else{ | ||
| 46 | + if(body.status == 1){ | ||
| 47 | + console.log('START',json) | ||
| 48 | + ws.send(JSON.stringify(json)) | ||
| 49 | + }else if(body.status == 2){ | ||
| 50 | + json.type = 'STOP' | ||
| 51 | + ws.on('open', function open() { | ||
| 52 | + ws.send(JSON.stringify(json)) | ||
| 53 | + }); | ||
| 54 | + } | ||
| 38 | } | 55 | } |
| 56 | + ws.on('close', function close() { | ||
| 57 | + console.log('disconnected'); | ||
| 58 | + }); | ||
| 39 | // if(channelInfo){ | 59 | // if(channelInfo){ |
| 40 | // if(body.status == 2){ | 60 | // if(body.status == 2){ |
| 41 | // var channelInfo = await recordStatus.update({status:3},{where:{channel:channel}}); | 61 | // var channelInfo = await recordStatus.update({status:3},{where:{channel:channel}}); |
| @@ -61,7 +81,6 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ | @@ -61,7 +81,6 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ | ||
| 61 | // await callfile.exec(shell) | 81 | // await callfile.exec(shell) |
| 62 | return true | 82 | return true |
| 63 | } catch (error) { | 83 | } catch (error) { |
| 64 | - | ||
| 65 | throw error | 84 | throw error |
| 66 | } | 85 | } |
| 67 | 86 |
-
请 注册 或 登录 后发表评论