付智勇

ws 重新开始链接添加

... ... @@ -5,9 +5,8 @@ const uuid = require('../../UuidUtil');
const moment = require('moment')
const WebSocket = require('ws');
const ws = new WebSocket('ws://115.29.208.81:5000', {
perMessageDeflate: false
});
var ws = new WebSocket('ws://123.56.204.132:5000', {
});
function shell(){
... ... @@ -27,15 +26,36 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{
"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))
if(ws.readyState == 3){
ws = new WebSocket('ws://123.56.204.132:5000', {
});
if(body.status == 1){
console.log('START',json)
setTimeout(function() {
console.log( ws.readyState)
ws.send(JSON.stringify(json))
}, 20);
}else if(body.status == 2){
json.type = 'STOP'
setTimeout(function() {
console.log( ws.readyState)
ws.send(JSON.stringify(json))
}, 20);
}
}else{
if(body.status == 1){
console.log('START',json)
ws.send(JSON.stringify(json))
}else if(body.status == 2){
json.type = 'STOP'
ws.on('open', function open() {
ws.send(JSON.stringify(json))
});
}
}
ws.on('close', function close() {
console.log('disconnected');
});
// if(channelInfo){
// if(body.status == 2){
// var channelInfo = await recordStatus.update({status:3},{where:{channel:channel}});
... ... @@ -61,7 +81,6 @@ shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{
// await callfile.exec(shell)
return true
} catch (error) {
throw error
}
... ...