Browse Source

萤石状态广播测试

release_0.0.2
巴林闲侠 3 years ago
parent
commit
fa513c5e8e
  1. 10
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js
  2. 37
      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 errMsg = (handleCameraId ? '修改' : '添加') + errMsg
const beloneSecret = await verifyYingshiInfo({ serialNo }) const beloneSecret = await verifyYingshiInfo({ serialNo })
const corGbYingshiRes = await models.GbCamera.findOne({
where: {
streamid: String(serialNo).toUpperCase(),
ipctype: 'yingshi'
}
})
let storageData = { let storageData = {
type: 'yingshi', name, cloudControl, highDefinition, memoryCard, type: 'yingshi', name, cloudControl, highDefinition, memoryCard,
voice, longitude, latitude, kindId, rtmp, voice, longitude, latitude, kindId, rtmp,
serialNo: String(serialNo).toUpperCase(), serialNo: String(serialNo).toUpperCase(),
yingshiSecretId: beloneSecret.id yingshiSecretId: beloneSecret.id,
gbId: corGbYingshiRes ? corGbYingshiRes.id : null
} }
if (handleCameraId) { if (handleCameraId) {

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

@ -4,7 +4,7 @@ const moment = require('moment')
module.exports = function (app, opts) { module.exports = function (app, opts) {
const freshYingshiState = schedule.scheduleJob( const freshYingshiState = schedule.scheduleJob(
// '* * 4 * * *', // '* * 4 * * *',
'*/3 * * * *', '*/1 * * * *',
async () => { async () => {
try { try {
@ -54,15 +54,46 @@ module.exports = function (app, opts) {
// 状态推送 // 状态推送
const { connected } = app.socket.sockets const { connected } = app.socket.sockets
const roomId = 'ROOM_' + Math.random() + '_' + d.deviceSerial const roomId = 'ROOM_' + Math.random() + '_' + d.deviceSerial
let cameraName = ''
if (connected) { if (connected) {
for (let c in connected) { for (let c in connected) {
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) 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 { } 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++ pageStart++

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

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

Loading…
Cancel
Save