Browse Source

萤石状态广播测试

release_0.0.2
巴林闲侠 2 years ago
parent
commit
fa513c5e8e
  1. 10
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js
  2. 39
      code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiState.js
  3. 2
      code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js

10
code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js

@ -36,12 +36,18 @@ async function createYingshi (ctx) {
errMsg = (handleCameraId ? '修改' : '添加') + errMsg
const beloneSecret = await verifyYingshiInfo({ serialNo })
const corGbYingshiRes = await models.GbCamera.findOne({
where: {
streamid: String(serialNo).toUpperCase(),
ipctype: 'yingshi'
}
})
let storageData = {
type: 'yingshi', name, cloudControl, highDefinition, memoryCard,
voice, longitude, latitude, kindId, rtmp,
serialNo: String(serialNo).toUpperCase(),
yingshiSecretId: beloneSecret.id
yingshiSecretId: beloneSecret.id,
gbId: corGbYingshiRes ? corGbYingshiRes.id : null
}
if (handleCameraId) {

39
code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiState.js

@ -4,7 +4,7 @@ const moment = require('moment')
module.exports = function (app, opts) {
const freshYingshiState = schedule.scheduleJob(
// '* * 4 * * *',
'*/3 * * * *',
'*/1 * * * *',
async () => {
try {
@ -54,15 +54,46 @@ module.exports = function (app, opts) {
// 状态推送
const { connected } = app.socket.sockets
const roomId = 'ROOM_' + Math.random() + '_' + d.deviceSerial
let cameraName = ''
if (connected) {
for (let c in connected) {
connected[c].join(roomId)
const { client: { conn: { request: { _query } } } } = connected[c]
if (_query && _query.token) {
let userInfo = await app.redis.hget(_query.token, 'userInfo');
if (userInfo) {
userInfo = JSON.parse(userInfo)
const corCameraRes = await models.Camera.findOne({
where: {
gbId: existD.id,
createUserId: userInfo.id
}
})
// TODO 管理员判断
if (corCameraRes) {
cameraName = corCameraRes.name
connected[c].join(roomId)
}
}
}
}
app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, })
app.socket.to(roomId).emit('CAMERA_ONLINE', {
ipctype: 'yingshi',
online: storageD.online,
gbId: existD.id,
name: cameraName
})
}
}
} else {
await models.GbCamera.create(storageD)
const yingshiRes = await models.GbCamera.create(storageD)
await models.Camera.update({
gbId: yingshiRes.id
}, {
where: {
serialNo: d.deviceSerial
}
})
}
}
pageStart++

2
code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js

@ -18,7 +18,7 @@ export function initWebSocket ({ ioUrl, token }) {
type: '',
}
}
console.log(ioUrl);
return dispatch => {
const socket = io(ioUrl, {
query: {

Loading…
Cancel
Save