tcp send重连修改
This commit is contained in:
parent
f35cf5fd22
commit
bf0e77bf1f
@ -203,7 +203,6 @@ export async function delPic(day,type) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
export async function takePhoto(param, context, dir, flag = 1, callback?) {
|
||||
var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`;
|
||||
// var video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`;
|
||||
@ -225,9 +224,9 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) {
|
||||
return new Promise<takePhotoParam>(async (resolve, reject) => {
|
||||
const time = await getCurrentTime()
|
||||
const date = time.split(' ')[0]
|
||||
await fileHelper.createAlbum(date)
|
||||
rtsp_server.getVideoSnapshot(context, video_uri, fileName, '/jt', true,async (err, snapResult) => {
|
||||
console.log('baoyihubaoyihu', video_uri, flag, JSON.stringify(snapResult.fileSize))
|
||||
let dirName=dir?dir:date
|
||||
rtsp_server.getVideoSnapshot(context, video_uri, fileName,dirName, true,async (err, snapResult) => {
|
||||
console.log('baoyihubaoyihu', video_uri, flag,fileName,dir, JSON.stringify(snapResult.fileSize))
|
||||
console.log('getPhtot', JSON.stringify(snapResult))
|
||||
if(snapResult.result&&snapResult.errorCode==0){
|
||||
resolve({
|
||||
@ -248,8 +247,10 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) {
|
||||
});
|
||||
})
|
||||
}
|
||||
console.log('getmyLog03')
|
||||
|
||||
}
|
||||
export async function deleteAllPicturesFn(){
|
||||
fileHelper.deleteAllPictures();
|
||||
deleteAllVideos(globalThis.context,photoAccessHelper.AlbumType.USER,photoAccessHelper.AlbumSubtype.VIDEO)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ export default class TcpClient {
|
||||
private oppositeIp: string = ''
|
||||
private oppositeIpPort: string = ''
|
||||
private num: number = 0//重连次数
|
||||
private tcpSendNum: number = 0//重连次数
|
||||
private folderPath
|
||||
|
||||
private tcp: any = null
|
||||
@ -150,12 +151,12 @@ export default class TcpClient {
|
||||
promise.then(() => {
|
||||
reslove(true)
|
||||
}).catch(err => {
|
||||
globalThis.tcpSendNum++
|
||||
if(!globalThis.getCloseTcp&&globalThis.tcpSendNum>5){
|
||||
this.tcpSendNum++
|
||||
if(!globalThis.getCloseTcp&&this.tcpSendNum>10){
|
||||
setTimeout(async () => {
|
||||
getTCP(true)
|
||||
}, 3000)
|
||||
globalThis.tcpSendNum=0
|
||||
this.tcpSendNum=0
|
||||
return
|
||||
}
|
||||
globalThis.getCloseTcp=true
|
||||
|
||||
@ -2,7 +2,7 @@ import common from '@ohos.app.ability.common';
|
||||
import router from '@ohos.router';
|
||||
import { getCarInfo, getDeviceInfo } from '../common/service/terminalService';
|
||||
import { setCurrentTime } from '../common/service/timeService';
|
||||
import { string2Bytes } from '../common/utils/tools';
|
||||
import { getCurrentTime, string2Bytes } from '../common/utils/tools';
|
||||
import { FileHelper } from '../common/service/FileHelper';
|
||||
import { getEsCarModel, } from '../common/service/initable';
|
||||
import FileUtil from '../common/utils/File';
|
||||
@ -20,7 +20,9 @@ import { getSyncData } from '../common/service/initable';
|
||||
import GetDistance from '../common/utils/GetDistance'
|
||||
import UdpEvent from '../common/utils/UdpEvent'
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService';
|
||||
import {
|
||||
deleteAllPicturesFn,
|
||||
endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService';
|
||||
import imageBtn from './compontents/imageBtn'
|
||||
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||
|
||||
@ -85,6 +87,7 @@ struct Index {
|
||||
// type: 1,
|
||||
// name: 'button_media.wav'
|
||||
// })
|
||||
// deleteAllPicturesFn()
|
||||
if (this.loading) {
|
||||
return
|
||||
}
|
||||
@ -334,6 +337,7 @@ struct Index {
|
||||
}
|
||||
|
||||
async aboutToAppear() {
|
||||
|
||||
console.log('diyidiy')
|
||||
this.avPlayer = new VoiceAnnounce();
|
||||
this.initParamFlag=false
|
||||
@ -467,7 +471,6 @@ struct Index {
|
||||
}
|
||||
this.isSingle = globalThis.singlePlay
|
||||
// this.loading = false
|
||||
this.createAlbum()
|
||||
this.num = 0
|
||||
// const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
|
||||
globalThis.lsh = '1111111111111'
|
||||
@ -475,8 +478,11 @@ struct Index {
|
||||
|
||||
async createAlbum() {
|
||||
this.fileHelper = new FileHelper();
|
||||
const time = await getCurrentTime()
|
||||
const date = time.split(' ')[0]
|
||||
this.fileHelper.createAlbum('jt')
|
||||
this.fileHelper.createAlbum('pz');
|
||||
this.fileHelper.createAlbum(date);
|
||||
|
||||
}
|
||||
|
||||
@ -545,6 +551,7 @@ struct Index {
|
||||
this.heartMsg()
|
||||
}
|
||||
}, 1000)
|
||||
this.createAlbum()
|
||||
//下载模型
|
||||
// await this.getModel()
|
||||
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user