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