WO2021088773A1 - 一种显示报警文件的方法、装置及系统 - Google Patents

一种显示报警文件的方法、装置及系统 Download PDF

Info

Publication number
WO2021088773A1
WO2021088773A1 PCT/CN2020/125955 CN2020125955W WO2021088773A1 WO 2021088773 A1 WO2021088773 A1 WO 2021088773A1 CN 2020125955 W CN2020125955 W CN 2020125955W WO 2021088773 A1 WO2021088773 A1 WO 2021088773A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
alarm
alarm file
data packet
length
Prior art date
Application number
PCT/CN2020/125955
Other languages
English (en)
French (fr)
Inventor
薛行明
王志海
唐朱震
Original Assignee
杭州海康威视数字技术股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 杭州海康威视数字技术股份有限公司 filed Critical 杭州海康威视数字技术股份有限公司
Priority to US17/772,811 priority Critical patent/US20220414178A1/en
Priority to EP20885783.9A priority patent/EP4044513A4/en
Publication of WO2021088773A1 publication Critical patent/WO2021088773A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9566URL specific, e.g. using aliases, detecting broken or misspelled links
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/168Details of user interfaces specifically adapted to file systems, e.g. browsing and visualisation, 2d or 3d GUIs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • G06F16/1824Distributed file systems implemented using Network-attached Storage [NAS] architecture
    • G06F16/183Provision of network file services by network file servers, e.g. by using NFS, CIFS
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/04Network management architectures or arrangements
    • H04L41/045Network management architectures or arrangements comprising client-server management architectures

Definitions

  • This application relates to the field of communications, and in particular to a method, device and system for displaying alarm files.
  • a browser can be used to request an alarm file from the server, and the alarm file can be displayed through the browser.
  • the alarm file can be an alarm picture, etc.
  • the server first saves the alarm file after obtaining the alarm file for the browser to request.
  • the browser can request an alarm file from the server by polling, that is, the browser sends a request message to the server every period of time, and the server receives the request message. If the alarm file is currently saved, it sends the request message to the browser.
  • the uniform resource locator (URL) of the alarm file The browser obtains the original data through the URL of the alarm file and parses it into an alarm file displayed by normal pixels; if the alarm file is not saved, the browser is notified.
  • the server needs to send the URL of the alarm file accessible on the server to the browser so that the browser can display the alarm file according to the URL.
  • the server needs to save the alarm file, which wastes a lot of storage resources on the server.
  • the embodiments of the present application provide a method, device, system, electronic device, computer-readable storage medium, and computer program product for displaying alarm files, so as to reduce the waste of storage resources on the server side.
  • the technical solution is as follows:
  • this application provides a method for displaying an alarm file, the method including:
  • the alarm file is displayed according to the URL of the alarm file.
  • the alarm file corresponds to M data packets, where M is an integer greater than or equal to 1, and the analysis of the data packets corresponding to the alarm file to obtain the alarm file includes:
  • the check character string is a preset check character string
  • the data belonging to the alarm file stored in the storage structure is the alarm file.
  • the header of the data packet further includes the length of the payload of the data packet
  • the storing the payload part of the data packet in the storage space corresponding to the packet sequence number in the storage structure corresponding to the file identifier includes:
  • the file identifier determine whether the data packet is the first received data packet belonging to the alarm file
  • a storage structure corresponding to the file identifier is created, the payload part of the data packet is saved in the storage space corresponding to the packet sequence number in the storage structure, and in the storage structure Save the data length belonging to the alarm file, where the data length is equal to the payload length of the data packet;
  • the storage structure corresponding to the file identifier is determined, the payload part of the data packet is saved in the storage space corresponding to the packet sequence number in the storage structure, and the storage structure is The saved data length belonging to the alarm file and the payload length of the data packet are accumulated to obtain an accumulated value, and the data length saved in the storage structure is replaced with the accumulated value.
  • the parsed alarm file is stored in a memory
  • the uniform resource locator URL for generating the alarm file includes:
  • the URL of the alarm file is generated through an application program interface API for generating a uniform resource locator URL.
  • the method before the receiving the data packet corresponding to the alarm file sent by the server through the long connection with the server, the method further includes:
  • the alarm information corresponding to the alarm file is received through the long connection, and the content of the alarm file belongs to the content type.
  • the present application provides a device for displaying alarm files, and the device includes:
  • a receiving module configured to receive a data packet corresponding to the alarm file sent by the server through a long connection with the server, wherein the server releases the storage resources occupied by the alarm file after sending the alarm file;
  • a parsing module configured to parse the data packet corresponding to the alarm file to obtain the alarm file
  • the display module is used to display the alarm file according to the URL of the alarm file.
  • the alarm file corresponds to M data packets, and M is an integer greater than or equal to 1, and the parsing module is configured to:
  • the check character string is a preset check character string
  • the data belonging to the alarm file stored in the storage structure is the alarm file.
  • the header of the data packet further includes the length of the payload of the data packet
  • the parsing module is used for:
  • the file identifier determine whether the data packet is the first received data packet belonging to the alarm file
  • a storage structure corresponding to the file identifier is created, the payload part of the data packet is saved in the storage space corresponding to the packet sequence number in the storage structure, and in the storage structure Save the data length belonging to the alarm file, where the data length is equal to the payload length of the data packet;
  • the storage structure corresponding to the file identifier is determined, the payload part of the data packet is saved in the storage space corresponding to the packet sequence number in the storage structure, and the storage structure is The saved data length belonging to the alarm file and the payload length of the data packet are accumulated to obtain an accumulated value, and the data length saved in the storage structure is replaced with the accumulated value.
  • the alarm file obtained by the analysis is stored in the memory, and the generating module is configured to:
  • the URL of the alarm file is generated through an application program interface API for generating a uniform resource locator URL.
  • the device further includes: a sending module,
  • the sending module is configured to send a subscription request message to the server through the long connection, the subscription request message including the content type;
  • the receiving module is further configured to receive the alarm information corresponding to the alarm file through the long connection, and the content of the alarm file belongs to the content type.
  • this application provides a system for displaying alarm files, and the system includes: a client and a server;
  • the server is configured to send a data packet corresponding to the alarm file to the client through a long connection with the client to release the storage resources occupied by the alarm file;
  • the client is configured to receive the data packet corresponding to the alarm file through a long connection with the server; analyze the data packet corresponding to the alarm file to obtain the alarm file; generating the alarm file Uniform resource locator URL; the alarm file is displayed according to the URL of the alarm file.
  • the alarm file corresponds to M data packets, and M is an integer greater than or equal to 1, and the client is used for:
  • the check character string is a preset check character string
  • the data belonging to the alarm file stored in the storage structure is the alarm file.
  • the header of the data packet further includes the length of the payload of the data packet
  • the client is used for:
  • the file identifier determine whether the data packet is the first received data packet belonging to the alarm file
  • a storage structure corresponding to the file identifier is created, the payload part of the data packet is saved in the storage space corresponding to the packet sequence number in the storage structure, and in the storage structure Save the data length belonging to the alarm file, where the data length is equal to the payload length of the data packet;
  • the storage structure corresponding to the file identifier is determined, the payload part of the data packet is saved in the storage space corresponding to the packet sequence number in the storage structure, and the storage structure is The saved data length belonging to the alarm file and the payload length of the data packet are accumulated to obtain an accumulated value, and the data length saved in the storage structure is replaced with the accumulated value.
  • the client is configured to store the parsed alarm file in the memory, and generate the alarm file according to the alarm file stored in the memory through an application program interface API used to generate a uniform resource locator URL.
  • the URL of the alarm file is configured to store the parsed alarm file in the memory, and generate the alarm file according to the alarm file stored in the memory through an application program interface API used to generate a uniform resource locator URL.
  • the URL of the alarm file is configured to store the parsed alarm file in the memory, and generate the alarm file according to the alarm file stored in the memory through an application program interface API used to generate a uniform resource locator URL.
  • the client is further configured to send a subscription request message to the server through the persistent connection, the subscription request message includes the content type; the alarm information corresponding to the alarm file is received through the persistent connection, so The content of the alarm file belongs to the content type;
  • the server is also configured to send the alarm information corresponding to the alarm file to the client through the long connection.
  • an embodiment of the present application provides an electronic device, including at least one processor and at least one memory, the at least one memory is used to store at least one instruction, and the at least one instruction is loaded by the at least one processor And run to achieve the above method of displaying the alarm file.
  • an embodiment of the present application provides a computer-readable storage medium for storing at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the above-mentioned method for displaying an alarm file.
  • an embodiment of the present application provides a computer program product
  • the computer program product includes a computer program stored in a computer-readable storage medium, and the calculation program is loaded by a processor to realize the above-mentioned display alarm file Methods.
  • the client When the client displays the alarm file, it needs to be based on the URL of the alarm file. Because the client receives the data packet of the alarm file through a long connection, the alarm file is parsed from the data packet of the alarm file, and the URL of the alarm file is generated. The URL displays the alarm file, so that the server can send the alarm file to the client after obtaining the alarm file without saving the alarm file, which improves the real-time performance of pushing the alarm file. If the client uses the polling method, the server needs to save and obtain the alarm file first, so that the client can obtain the URL of the alarm file when polling the server, and then obtain and display the alarm file from the server according to the URL.
  • the server does not save the alarm file, and the storage resources can be released after the alarm file is pushed to the client, which reduces the occupation of storage resources on the server and avoids polling that causes a large consumption of server resources and bandwidth. Resources.
  • FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of another system architecture provided by an embodiment of the present application.
  • Fig. 3 is a flowchart of a method for obtaining an alarm file provided by an embodiment of the present application
  • FIG. 4 is a schematic diagram of an alarm file provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of the structure of a data packet provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of another data packet structure provided by an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of yet another data packet provided by an embodiment of the present application.
  • FIG. 8 is a flowchart of a method for displaying an alarm file provided by an embodiment of the present application.
  • Fig. 9 is a flowchart of another method for displaying an alarm file provided by an embodiment of the present application.
  • FIG. 10 is a schematic structural diagram of a device for displaying alarm files provided by an embodiment of the present application.
  • FIG. 11 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • an embodiment of the present application provides a system for displaying alarm files, and the system includes:
  • the server 1 and the client 2, and the client 2 can establish a long connection with the server 1.
  • the long connection may be a Websocket connection
  • the Websocket connection is a full-duplex two-way communication connection.
  • the client 2 may be a browser or other applications.
  • the server 1 can obtain the alarm file.
  • the file type of the alarm file can be a picture file, a video file or a text file, etc.
  • the server 1 may be a network video recorder (NVR) or a network camera (IP CAMERA, IPC), etc.
  • NVR network video recorder
  • IP CAMERA IP CAMERA, IPC
  • the server 1 obtains the alarm file by itself, for example, it can shoot the alarm file by itself.
  • the server 1 may also be a server. Referring to FIG. 2, the server 1 also establishes a connection with at least one surveillance camera 3.
  • the surveillance camera 3 can send alarm information to the server 1, and send at least one alarm file to the server 1 immediately after the alarm information.
  • the alarm information may include at least one of the number of alarm files to be sent, file description information of each alarm file, and equipment information of the surveillance camera 3.
  • the file description information of the alarm file may include the file content description information of the alarm file.
  • the file content description information may include whether the picture file is a background image or a foreground image, and/or whether the image in the picture file is It is an image of a specific object.
  • the file content description information may also include feature information of the object corresponding to the specific object image, such as at least one of age characteristics, height characteristics, and the like.
  • the device information of the surveillance camera 3 may include the address of the surveillance camera 3.
  • the address may include at least one of an Internet Protocol address (Internet Protocol Address, IP) address or a Media Access Control address (Media Access Control Address, MAC) address.
  • IP Internet Protocol Address
  • MAC Media Access Control Address
  • the client 2 after the client 2 establishes a long connection with the server 1 (which can be a Websocket connection), it can send a subscription request message to the server 1 through the long connection.
  • the subscription request message includes the content type for use in The content of the subscribed file in the server 1 belongs to the alarm file of the content type.
  • the content type can include a specific object image, for example, if the specific object is a vehicle, the content type can be a vehicle image. Assuming that the content type included in the subscription request message is a vehicle image, that is, the content of the subscription file in the server 1 belongs to the vehicle image. That is to say, when the server 1 obtains the alarm file belonging to the vehicle image, it sends the alarm file to the client 2.
  • the server 1 receives the subscription request message, and saves the content type included in the subscription request message.
  • the alarm information is sent to the client 2 through the persistent connection, and when the server 1 obtains the alarm file whose file content belongs to the content type
  • M is an integer greater than or equal to 1.
  • the server 1 sends the data packet to the client 2 through the long connection, and it is sending After the data packet, the storage resources occupied by the data packet are released.
  • the server can also release the storage resources occupied by the alarm file after sending the M data packets corresponding to the alarm file.
  • the server releasing the storage resources occupied by the alarm file includes releasing all resources or part of the resources occupied by the alarm file.
  • the storage resources occupied by the alarm file can be released: the server releases all or part of the resources occupied by the alarm file after sending all the alarm files; or the server releases the alarm file after sending part of the alarm file Part of the resources occupied.
  • the server releases the storage resources occupied by the M data packets after sending M data packets, or the server can also release Y data in the X data packets after sending X data packets of the alarm file Storage resources occupied by the package, where X is less than or equal to M, and Y is less than or equal to X.
  • the server 1 each time a data packet is encapsulated, the server 1 sends the data packet to the client 2 through the persistent connection.
  • the client terminal 2 can parse the received data packet to obtain the alarm file, generate the URL of the alarm file, and display the alarm file according to the URL of the alarm file.
  • the client 2 or the server 1 can also actively request to disconnect the persistent connection.
  • the data packet includes a packet header and a payload part located after the packet header.
  • the payload part includes the alarm file or part of the content in the alarm file.
  • the packet header may include a check field, a packet header length field, a file length field, a file identification field, and a packet sequence number field.
  • the check field is used to carry a preset check string
  • the header length field is used to carry the header length of the data packet
  • the file length field is used to carry the file length of the alarm file
  • the file identification field is used to carry the file identification of the alarm file
  • the packet sequence number field is used to carry the packet sequence number of the data packet.
  • fields such as the packet header length field, the file length field, the file identification field, and the packet sequence number field. There are many sorts of these fields in the packet header. In this application, an example of an arrangement order is listed for description, and other arrangement orders are not listed one by one.
  • the length of the check field is a bytes, a is an integer greater than 1, and the check field is the 0th to a-1 bytes of the header; the length of the header length field is b Byte, b is an integer greater than 1, and the header length field is from a to a+b-1 bytes of the header; the length of the file length field is c bytes, c is an integer greater than 1, and the file length field is The a+b to a+b+c-1 bytes of the header; the length of the file identification field is d bytes, d is an integer greater than 1, and the file identification field is the a+b+c to a of the header +b+c+d-1 bytes; and the length of the packet sequence number field is e bytes, where e is an integer greater than 1, and the packet sequence number field is from a+b+c+d to a+b+ in the header c+d+e-1 bytes.
  • the header of the data packet may further include a payload length field, and the payload length field may be used to carry the length of the payload part of the data packet.
  • the payload length field may be located between the file length field and the file identification field.
  • the length of the payload length field is f bytes, f is an integer greater than 1, and the payload length field is a+b+c to a+b+c+f-1 bytes in the header.
  • the file The identification field is a+b+c+f to a+b+c+d+f-1 bytes in the header
  • the packet sequence number field is a+b+c+d+f to a+b+ in the header c+d+f+e-1 bytes.
  • the header of the data packet may also include a file type field, and the file type field may be used to carry the file type of the alarm file.
  • the file type field can be located after the packet sequence number field.
  • the length of the file type field is g bytes, g is an integer greater than 1, and the file type field is from a+b+c+d+f+e to a+b+c+d+f+e+g in the header -1 byte.
  • the check field is the 0th to 3rd bytes of the header
  • the header length field is the 4th to 7th bytes of the header
  • the file length field is the 8th to 11th bytes of the header
  • the payload length field It is the 12th to 15th bytes of the header
  • the file identification field is the 16th to 47th bytes of the header
  • the packet sequence number field is the 48th to 51st bytes of the header
  • the file type field is the 52nd to 55th bytes of the header. byte.
  • the header of the data packet shown in Figure 6 can be defined as the following structure:
  • dwHeaderLen is the header length field, which only refers to the length of INTER_HEADER_BINARY, which is used for subsequent HEADER expansion;
  • dwDataLen is the file length field, which only refers to the total length of the file data (not including INTER_HEADER_BINARY);
  • dwIndex is the packet sequence number field, the packet index of the data packet after sub-packaging, indicating the number of data packets;
  • the client 2 receives the M data packets sent by the server 1 through the persistent connection; and obtains the alarm file by analyzing the header of each data packet of the M data packets.
  • an embodiment of the present application provides a method for displaying an alarm file, and the method includes:
  • Step 101 Receive a data packet corresponding to an alarm file sent by the server through a long connection with the server, where the server releases the storage resources occupied by the alarm file after sending the alarm file.
  • Step 102 Analyze the data packet corresponding to the alarm file to obtain the alarm file.
  • Step 103 Generate the uniform resource locator URL of the alarm file.
  • Step 104 Display the alarm file according to the URL of the alarm file.
  • the data packet corresponding to the alarm file of the server can be received through the long connection, the data packet corresponding to the alarm file is parsed to obtain the alarm file, and the URL of the alarm file is generated , So the alarm file is displayed according to the URL of the alarm file.
  • the server can push the alarm file to the client after it obtains the alarm file.
  • the alarm file can be saved, so that the storage resource occupied by the alarm file can be released after the alarm file is pushed, and the service is reduced.
  • the occupancy of storage resources at the end also avoids the large consumption of resources and bandwidth resources on the server end caused by polling, and improves the real-time performance of pushing alarm files. Since the URL of the alarm file is generated, the alarm file can be automatically displayed according to the URL.
  • an embodiment of the present application provides another method for displaying an alarm file, and the method includes:
  • Step 201 The client establishes a persistent connection with the server, and sends a subscription request message to the server through the persistent connection, where the subscription request message includes the content type.
  • the long connection may be a Websocket connection
  • the content type may include a specific object image.
  • the specific object image is a vehicle image, etc., that is, the content type may be a vehicle image.
  • Step 202 The server receives the subscription request message, the subscription request message carries the content type, and when the server obtains the alarm information that the information content belongs to the content type, it sends the alarm information to the client through the persistent connection.
  • the server After receiving the subscription request message, the server saves the content type included in the subscription request message. In this way, when the server obtains the alarm information whose information content belongs to the content type, the alarm information is sent to the client through the long connection.
  • Step 203 The client receives the alarm information.
  • the client can display alarm information. Since the alarm information includes the file description information of each alarm file and the equipment information of the surveillance camera, it can let the user know the status of the alarm file and other information.
  • Step 204 When the server obtains the alarm file whose file content belongs to the content type, it encapsulates the alarm file into M data packets.
  • step 202 and step 204 there is no sequential relationship between step 202 and step 204, that is, the server can send the alarm information first, and then encapsulate the data packet; or, encapsulate the data packet first, and then send the alarm information; or, encapsulate the data packet and send at the same time Alarm information.
  • the server After the server obtains the alarm information belonging to the content type, the server also obtains the alarm file whose file content belongs to the content type, and encapsulates the alarm file into M data packets.
  • the data packet may include a header and a payload part, and the header is located before the payload part.
  • the packet header may include a check field, a packet header length field, a file length field, a file identification field, and a packet sequence number field.
  • the check field is used to carry a preset check string
  • the header length field is used to carry the header length of the data packet
  • the file length field is used to carry the file length of the alarm file
  • the file identification field is used to carry the file identification of the alarm file
  • the packet sequence number field is used to carry the packet sequence number of the data packet.
  • the header of the data packet may further include a payload length field, and the payload length field may be used to carry the length of the payload portion of the data packet.
  • the payload length field may be located between the file length field and the file identification field.
  • the header of the data packet may further include a file type field, and the file type field may be used to carry the file type of the alarm file.
  • Step 205 The server sends the M data packets to the client through the long connection, and releases the storage resources occupied by the M data packets.
  • the server sends one data packet to the client each time on the long connection.
  • the server can also obtain the alarm file whose file content belongs to the content type, encapsulate the alarm file into at least one data packet through the above 204 or 205 process, and send the at least one data packet to the client through the persistent connection.
  • the server receives an alarm file whose file content belongs to the subscribed content type, it can send it to the client.
  • There is no need to store the alarm file so there is no need to poll the server, which improves the real-time nature of obtaining the alarm file. Avoid wasting server resources (for example, the resources may include storage resources) and bandwidth resources.
  • the server can release the storage resources occupied by the M data packets after sending the M data packets, or release the storage resources occupied by some of the M data packets, so as to release the storage occupied by the storage files Resources; after sending X data packets of the alarm file, the storage resources occupied by Y data packets in the X data packets can be released, where X is less than or equal to M, and Y is less than or equal to X; preferably, it can be sent every time After a data packet, the storage resources occupied by the data packet are released, thereby reducing the occupation of storage resources on the server side.
  • Step 206 The client receives the data packet, and reads the verification character string from the header of the data packet, and when the verification character string is a preset verification character string, reads the header length from the header.
  • the server It takes a while for the server to send the M data packets. During this period of time, the first part of the M data packets may be transmitted to the client, and the client receives the data packets.
  • the data packet received by the client is any one of the M data packets.
  • the data packet received by the client may be the first data packet of the alarm file or the last data packet of the alarm file. , It may be any data packet between the first data packet and the last data packet.
  • the check field is the first field in the header of the data packet, and its length is a bytes
  • the second field is the header length field, and its length is b bytes.
  • the first a byte of information is read from the header of the data packet to obtain a check string, and when the check string is a preset check string, the ath is read from the packet header of the data packet. Up to a+b-1 bytes of information, get the packet header length.
  • Step 207 The client reads the file length of the alarm file, the file identifier of the alarm file and the packet sequence number of the data packet from the packet header according to the length of the packet header.
  • the client can determine the remaining part of the header and the payload part of the data packet according to the length of the header, and read the remaining part of the header from the data packet.
  • the field after the header length field is the file length field, and the length of the file length field is c bytes. That is to say, the first field of the remaining part of the packet header is the file length field, and the information of the 0th to c-1 bytes is read from the remaining part of the packet header to obtain the file length of the alarm file.
  • the field after the file length field is the file identification field, and the length of the file identification field is d bytes.
  • the c to c+d-1 bytes of information are read from the remaining part of the packet header to obtain the file identifier of the alarm file.
  • the field after the file identification field is the packet sequence number field, and the length of the packet sequence number field is e bytes.
  • the c+d to c+d+e-1 bytes of information are read from the remaining part of the packet header to obtain the packet sequence number of the data packet.
  • the header of the data packet may further include a payload length field, and the payload length field may be used to carry the length of the payload part of the data packet.
  • the payload length field may be located between the file length field and the file identification field.
  • the length of the payload length field is f bytes.
  • the header of the data packet shown in FIG. 5 read the information of the 0th to c-1 bytes from the remaining part of the header to obtain the file length of the alarm file.
  • the header of the data packet may further include a file type field, and the file type field may be used to carry the file type of the alarm file.
  • the file type field can be located after the packet sequence number field.
  • the length of the file type field is g bytes.
  • Step 208 The client saves the payload part of the data packet in the storage space corresponding to the packet sequence number in the storage structure corresponding to the file identifier.
  • a storage structure is used to buffer the received payload of each data packet belonging to the alarm file.
  • the storage structure corresponds to the file identifier of the alarm file, and the storage structure includes at least one storage space.
  • Each data packet belonging to the alarm file corresponds to one storage space, and each data packet corresponds to a different storage space.
  • the client may be a browser, and the storage structure may be located in the memory of the browser.
  • the storage structure may be an array.
  • the storage structure corresponding to the file identifier is created.
  • the payload part of the data packet is saved in the storage space corresponding to the packet sequence number; if it is not the first one, the storage structure corresponding to the file identifier is determined, and the payload of the data packet is stored in the storage structure. Part of it is saved in the storage space corresponding to the packet serial number.
  • the payload length of the data packet carried in the payload length field may be compared with the actual payload portion of the data. Are the lengths equal. If they are equal, it indicates that no data loss has occurred in the payload portion of the data, and the payload portion of the data packet is saved in the storage space corresponding to the packet sequence number. If they are not equal, it indicates that data loss has occurred in the payload part of the data packet, and the data of the alarm file stored in the storage structure is discarded.
  • the server may not release the storage resources occupied by the alarm file immediately after sending the data packet of the alarm file, so if the client discards the data of the alarm file stored in the storage structure, the client can request the server to send The data packet included in the alarm file.
  • the client can notify the server after receiving the data packet included in the alarm file, and the server releases the storage resources occupied by the alarm file after receiving the notification.
  • the payload part of the data packet can also be saved in the storage space corresponding to the serial number of the packet, so that part of the content of the displayed alarm file may be missing. For example, assuming that the alarm file is a picture, some of the content in the displayed picture is missing.
  • the packet sequence number can be sequentially numbered starting from 1, the packet sequence number 1 corresponds to the first storage space in the storage structure, the packet sequence number 2 corresponds to the second storage space in the data group, and so on.
  • the packet sequence number 1 corresponds to the first storage space in the storage structure
  • the packet sequence number 2 corresponds to the second storage space in the data group
  • the header of the data packet also includes the payload length of the data packet
  • the storage structure also stores the data length belonging to the alarm file. Specifically, it may be when the first data belonging to the alarm file is received.
  • the data length belonging to the alarm file is stored in the storage structure, and the data length is equal to the payload length of the first data packet; the received data packet belonging to the alarm file is not the first
  • the payload part of the data packet is stored in the storage space corresponding to the packet serial number
  • the data length of the alarm file stored in the storage structure and the The payload length of the data packet is accumulated to obtain the accumulated value, and the data length belonging to the alarm file stored in the storage structure is replaced with the accumulated value.
  • step 209 After replacing the data length of the alarm file stored in the storage structure with the accumulated value, it is also judged whether the data length of the alarm file stored in the storage structure is equal to the file length of the alarm file, if If it is equal to, step 209 is executed, and if it is not equal, the client re-executes operations 206 to 208 when the data packet is received.
  • Step 209 When the length of the data belonging to the alarm file saved by the client in the storage structure is equal to the file length of the alarm file, the data belonging to the alarm file stored in the storage structure is the alarm file, and the URL of the alarm file is generated .
  • the client provides an application programming interface (Application Programming Interface, API) used to generate URLs.
  • API Application Programming Interface
  • the client can call the API, input the alarm file stored in the storage structure into the API, and generate the URL of the alarm file through the API.
  • the URL of the alarm file can be generated when the file type of the alarm file is picture or video.
  • the URL may be a temporary URL of the alarm file.
  • the client can save the alarm file in the client's memory, and count the number of alarm files saved in the client's memory.
  • the client's memory Delete the earliest saved alarm file. This can prevent the client's memory from being unrestrictedly occupied and not effectively released.
  • a management storage structure may be set, and the number of storage spaces included in the management storage structure is a preset number threshold.
  • the URL of the alarm file if there is still free storage space in the management storage structure, use the current time as the storage time of the generated alarm file, and save the URL of the generated alarm file and the storage time to the management storage structure.
  • a free storage space if there is no free storage space in the management storage structure, find the URL of the alarm file with the earliest storage time from the management storage structure, and delete the alarm corresponding to the URL with the earliest storage time from the client's memory File, clear the storage space where the URL with the earliest storage time is located, and save the URL and storage time of the generated alarm file in the emptied storage space.
  • the management storage structure is an array, etc.
  • Step 210 The client displays the alarm file according to the URL of the alarm file.
  • the client is a browser
  • the browser is based on the URL of the picture or video to display
  • the URL of the alarm file is generated through the API used to generate the URL, so that you can browse
  • the device can automatically display the alarm file according to the URL.
  • the browser can also directly display the text file without generating the URL of the text file.
  • the long connection between the client and the server can be actively disconnected by the client or the server.
  • the client because the client displays the alarm file based on the URL of the alarm file, the client establishes a long connection with the server and sends the subscription request message to the server, so that the server receives the file content
  • the alarm file belongs to the content type, M data packets are sent, the alarm file is parsed from the M data packets, and the URL of the alarm file is generated, so that the client can display the alarm file based on the generated URL, thereby improving the sending of the alarm file.
  • Efficiency it also avoids polling that causes a large consumption of server resources and bandwidth resources. Compared with polling to get the URL corresponding to the alarm file in the server, the server has limited storage space.
  • the alarm file obtained later on the server will overwrite the alarm file previously obtained, but if the client is overwritten If the polling is not available, the overwritten alarm file cannot be pushed to the client for display, resulting in unreliable display of the alarm file.
  • each alarm file can be pushed and displayed, which improves the reliability of displaying alarm files.
  • the client polls to get the URL, because this solution stores the alarm file in the memory of the client and generates the URL corresponding to the alarm file, the server does not need to store the alarm file, and push the alarm After the file, the storage resources occupied by the alarm file can be released, reducing the storage space occupied by the server.
  • the packet header of the data packet includes a check field, a header length field, a file length field, a file identification field, and a packet sequence number field.
  • the check field is used to carry a preset check string
  • the header length field is used to carry the header length of the data packet
  • the file length field is used to carry the file length of the alarm file
  • the file identification field is used to carry the file identification of the alarm file
  • the packet sequence number field is used to carry the packet sequence number of the data packet. In this way, based on the fields in the packet header, M data packets belonging to an alarm file can be successfully identified, and the alarm file can be parsed.
  • an embodiment of the present application provides a device 300 for displaying an alarm file, and the device 300 includes:
  • the receiving module 301 is configured to receive the data packet corresponding to the alarm file sent by the server through a long connection with the server, wherein the server releases the storage resources occupied by the alarm file after sending the alarm file;
  • the parsing module 302 is configured to analyze the data packet corresponding to the alarm file to obtain the alarm file;
  • the generating module 303 is used to generate the uniform resource locator URL of the alarm file
  • the display module 304 is configured to display the alarm file according to the URL of the alarm file.
  • the alarm file corresponds to M data packets, and M is an integer greater than or equal to 1, and the parsing module 302 is configured to:
  • the check character string is a preset check character string
  • the data belonging to the alarm file stored in the storage structure is taken as the alarm file.
  • the header of the data packet further includes the length of the payload of the data packet
  • the parsing module 302 is used to:
  • the file identifier determine whether the data packet is the first received data packet belonging to the alarm file
  • a storage structure corresponding to the file identifier is created, the payload part of the data packet is saved in the storage space corresponding to the packet sequence number in the storage structure, and in the storage structure Save the data length belonging to the alarm file, where the data length is equal to the payload length of the data packet;
  • the storage structure corresponding to the file identifier is determined, the payload part of the data packet is saved in the storage space corresponding to the packet sequence number in the storage structure, and the storage structure is The saved data length belonging to the alarm file and the payload length of the data packet are accumulated to obtain an accumulated value, and the data length saved in the storage structure is replaced with the accumulated value.
  • the alarm file obtained by the analysis is stored in the memory, and the generating module 303 is configured to:
  • the URL of the alarm file is generated through an application program interface API for generating a uniform resource locator URL.
  • the device 300 further includes: a sending module,
  • the sending module is configured to send a subscription request message to the server through the long connection, the subscription request message including the content type;
  • the receiving module is further configured to receive the alarm information corresponding to the alarm file through the long connection, and the content of the alarm file belongs to the content type.
  • the display module needs to display the alarm file based on the URL of the alarm file. Due to the long connection with the server, the receiving module can receive the data packet corresponding to the alarm file of the server through the long connection, and the parsing module The data packet corresponding to the alarm file is parsed to obtain the alarm file.
  • the generation module generates the URL of the alarm file through the API used to generate the URL.
  • the display module can automatically display the alarm file according to the URL, so that the server can automatically display the alarm file after obtaining the alarm file. , You can send the alarm file to the device without saving the alarm file.
  • the storage resource occupied by the alarm file can be released, which improves the real-time performance of pushing the alarm file and reduces the occupation of storage resources on the server. It also avoids polling that causes a large consumption of server resources and bandwidth resources.
  • FIG. 11 shows a structural block diagram of an electronic device 400 provided by an exemplary embodiment of the present application.
  • the electronic device 400 can run the aforementioned client, which can be a portable mobile terminal, such as a smart phone, a tablet computer, a notebook computer, or a desktop computer.
  • the electronic device 400 may also be called user equipment, portable terminal, laptop terminal, desktop terminal and other names.
  • the electronic device 400 includes a processor 401 and a memory 402.
  • the processor 401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on.
  • the processor 401 may adopt at least one hardware form among DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array, Programmable Logic Array). achieve.
  • the processor 401 may also include a main processor and a coprocessor.
  • the main processor is a processor used to process data in the awake state, also called a CPU (Central Processing Unit, central processing unit); the coprocessor is A low-power processor used to process data in the standby state.
  • the processor 401 may be integrated with a GPU (Graphics Processing Unit, image processor), and the GPU is used to render and draw content that needs to be displayed on the display screen.
  • the processor 401 may also include an AI (Artificial Intelligence) processor, and the AI processor is used to process computing operations related to machine learning.
  • AI Artificial Intelligence
  • the memory 402 may include one or more computer-readable storage media, which may be non-transitory.
  • the memory 402 may also include high-speed random access memory and non-volatile memory, such as one or more magnetic disk storage devices and flash memory storage devices.
  • the non-transitory computer-readable storage medium in the memory 402 is used to store at least one instruction, and the at least one instruction is used to be executed by the processor 401 to implement the display alarm provided by the method embodiment of the present application. File method.
  • the electronic device 400 may optionally further include: a peripheral device interface 403 and at least one peripheral device.
  • the processor 401, the memory 402, and the peripheral device interface 403 may be connected by a bus or a signal line.
  • Each peripheral device can be connected to the peripheral device interface 403 through a bus, a signal line, or a circuit board.
  • the peripheral device includes: at least one of a radio frequency circuit 404, a touch display screen 405, a camera 406, an audio circuit 407, a positioning component 408, and a power supply 409.
  • the peripheral device interface 403 can be used to connect at least one peripheral device related to I/O (Input/Output) to the processor 401 and the memory 402.
  • the processor 401, the memory 402, and the peripheral device interface 403 are integrated on the same chip or circuit board; in some other embodiments, any one of the processor 401, the memory 402, and the peripheral device interface 403 or The two can be implemented on a separate chip or circuit board, which is not limited in this embodiment.
  • the radio frequency circuit 404 is used for receiving and transmitting RF (Radio Frequency, radio frequency) signals, also called electromagnetic signals.
  • the radio frequency circuit 404 communicates with a communication network and other communication devices through electromagnetic signals.
  • the radio frequency circuit 404 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals.
  • the radio frequency circuit 404 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and so on.
  • the radio frequency circuit 404 can communicate with other terminals through at least one wireless communication protocol.
  • the wireless communication protocol includes but is not limited to: World Wide Web, Metropolitan Area Network, Intranet, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area network and/or WiFi (Wireless Fidelity, wireless fidelity) network.
  • the radio frequency circuit 404 may also include a circuit related to NFC (Near Field Communication), which is not limited in this application.
  • the display screen 405 is used to display a UI (User Interface, user interface).
  • the UI can include graphics, text, icons, videos, and any combination thereof.
  • the display screen 405 also has the ability to collect touch signals on or above the surface of the display screen 405.
  • the touch signal can be input to the processor 401 as a control signal for processing.
  • the display screen 405 may also be used to provide virtual buttons and/or virtual keyboards, also called soft buttons and/or soft keyboards.
  • the display screen 405 may be a flexible display screen, which is arranged on the curved surface or the folding surface of the electronic device 400. Furthermore, the display screen 405 can also be set as a non-rectangular irregular figure, that is, a special-shaped screen.
  • the display screen 405 may be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
  • the camera assembly 406 is used to capture images or videos.
  • the camera assembly 406 includes a front camera and a rear camera.
  • the front camera is arranged on the front panel of the electronic device 400
  • the rear camera is arranged on the back of the electronic device 400.
  • the camera assembly 406 may also include a flash.
  • the flash can be a single-color flash or a dual-color flash. Dual color temperature flash refers to a combination of warm light flash and cold light flash, which can be used for light compensation under different color temperatures.
  • the audio circuit 407 may include a microphone and a speaker.
  • the microphone is used to collect sound waves of the user and the environment, and convert the sound waves into electrical signals and input to the processor 401 for processing, or input to the radio frequency circuit 404 to implement voice communication.
  • the microphone can also be an array microphone or an omnidirectional collection microphone.
  • the speaker is used to convert the electrical signal from the processor 401 or the radio frequency circuit 404 into sound waves.
  • the speaker can be a traditional thin-film speaker or a piezoelectric ceramic speaker.
  • the audio circuit 407 may also include a headphone jack.
  • the positioning component 408 is used to locate the current geographic location of the electronic device 400 to implement navigation or LBS (Location Based Service, location-based service).
  • the positioning component 408 may be a positioning component based on the GPS (Global Positioning System, Global Positioning System) of the United States, the Beidou system of China, or the Galileo system of Russia.
  • the power supply 409 is used to supply power to various components in the electronic device 400.
  • the power source 409 may be alternating current, direct current, disposable batteries, or rechargeable batteries.
  • the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery.
  • a wired rechargeable battery is a battery charged through a wired line
  • a wireless rechargeable battery is a battery charged through a wireless coil.
  • the rechargeable battery can also be used to support fast charging technology.
  • the electronic device 400 further includes one or more sensors 410.
  • the one or more sensors 410 include, but are not limited to: an acceleration sensor 411, a gyroscope sensor 412, a pressure sensor 413, a fingerprint sensor 414, an optical sensor 415, and a proximity sensor 416.
  • the acceleration sensor 411 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the electronic device 400.
  • the acceleration sensor 411 may be used to detect the components of gravitational acceleration on three coordinate axes.
  • the processor 401 may control the touch screen 405 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 411.
  • the acceleration sensor 411 may also be used for the collection of game or user motion data.
  • the gyroscope sensor 412 can detect the body direction and rotation angle of the electronic device 400, and the gyroscope sensor 412 can cooperate with the acceleration sensor 411 to collect the user's 3D actions on the electronic device 400.
  • the processor 401 can implement the following functions according to the data collected by the gyroscope sensor 412: motion sensing (for example, changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
  • the pressure sensor 413 may be arranged on the side frame of the electronic device 400 and/or the lower layer of the touch screen 405.
  • the processor 401 performs left and right hand recognition or quick operation according to the holding signal collected by the pressure sensor 413.
  • the processor 401 controls the operability controls on the UI interface according to the user's pressure operation on the touch display screen 405.
  • the operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.
  • the fingerprint sensor 414 is used to collect the user's fingerprint.
  • the processor 401 identifies the user's identity according to the fingerprint collected by the fingerprint sensor 414, or the fingerprint sensor 414 identifies the user's identity according to the collected fingerprint.
  • the processor 401 authorizes the user to perform related sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings.
  • the fingerprint sensor 414 may be provided on the front, back or side of the electronic device 400. When the electronic device 400 is provided with a physical button or a manufacturer logo, the fingerprint sensor 414 may be integrated with the physical button or the manufacturer logo.
  • the optical sensor 415 is used to collect the ambient light intensity.
  • the processor 401 may control the display brightness of the touch screen 405 according to the ambient light intensity collected by the optical sensor 415. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 405 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 405 is decreased.
  • the processor 401 may also dynamically adjust the shooting parameters of the camera assembly 406 according to the ambient light intensity collected by the optical sensor 415.
  • the proximity sensor 416 also called a distance sensor, is usually provided on the front panel of the electronic device 400.
  • the proximity sensor 416 is used to collect the distance between the user and the front of the electronic device 400.
  • the processor 401 controls the touch screen 405 to switch from the on-screen state to the off-screen state; when the proximity sensor 416 When it is detected that the distance between the user and the front of the electronic device 400 is gradually increasing, the processor 401 controls the touch display screen 405 to switch from the on-screen state to the on-screen state.
  • FIG. 11 does not constitute a limitation on the electronic device 400, and may include more or fewer components than shown, or combine certain components, or adopt different component arrangements.
  • the data packet corresponding to the alarm file of the server can be received through the long connection.
  • the processor parses the data packet corresponding to the alarm file to obtain the alarm file, and generates the alarm file.
  • the URL of the alarm file so that the alarm file is displayed on the display according to the URL of the alarm file. In this way, the processor does not need to use the polling method to request the alarm file.
  • the server can push the alarm file to the electronic device when it gets the alarm file.
  • the alarm file may not be saved, so that the storage resource occupied by the alarm file can be released after the alarm file is pushed, reducing
  • the occupation of storage resources on the server side also avoids the large consumption of resources and bandwidth resources on the server side caused by polling, and improves the real-time performance of pushing alarm files. Since the processor generates the URL of the alarm file, the alarm file can be automatically displayed according to the URL.
  • the present disclosure also provides a computer-readable storage medium in which code instructions are stored, and the code instructions are executed by a processor to execute the alarm file display function provided by the above-mentioned embodiments.
  • the non-volatile computer-readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
  • the processor since the processor receives the data packet corresponding to the alarm file of the server through the persistent connection, the data packet corresponding to the alarm file is parsed to obtain the alarm file, and the URL of the alarm file is generated.
  • the alarm file is displayed.
  • the processor does not need to use the polling method to request the alarm file, so the server can not save the alarm file, so that the storage resource occupied by the alarm file can be released after the alarm file is pushed, reducing the storage resource occupation of the server, and avoiding The polling leads to a large consumption of server resources and bandwidth resources, and the real-time performance of pushing alarm files is improved. Since the processor generates the URL of the alarm file, the alarm file can be automatically displayed according to the URL.
  • the present disclosure also provides a computer program product.
  • the computer program product includes a computer program stored in a computer-readable storage medium, and the computer program is loaded by a processor to implement the foregoing implementation.
  • the example provides the method of displaying the alarm file.
  • the processor parses the data packet corresponding to the alarm file to obtain the alarm file, and generates the URL of the alarm file, so that the URL of the alarm file is generated according to the alarm file.
  • the URL shows the alarm file.
  • the processor does not need to use the polling method to request the alarm file, so that the server does not save the alarm file, so that the storage resource occupied by the alarm file can be released after the alarm file is pushed, reducing the storage resource occupation of the server, and avoiding Polling causes a large consumption of server resources and bandwidth resources, and improves the real-time performance of pushing alarm files. Since the processor generates the URL of the alarm file, the alarm file can be automatically displayed according to the URL.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Information Transfer Between Computers (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本申请是关于一种显示报警文件的方法、装置及系统,属于通信领域。所述方法包括:通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据包,其中所述服务端发送所述报警文件后释放所述报警文件占用的存储资源;对所述报警文件对应的数据包解析得到所述报警文件;生成所述报警文件的统一资源定位符URL;根据所述报警文件的URL显示所述报警文件。本申请能够减小浪费服务端的存储资源。

Description

一种显示报警文件的方法、装置及系统
本申请要求于2019年11月6日提交申请号为201911077085.2、发明名称为“一种显示报警文件的方法、装置及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及通信领域,特别涉及一种显示报警文件的方法、装置及系统。
背景技术
在安防行业中可以使用浏览器从服务端中请求报警文件,通过浏览器对报警文件进行显示。报警文件可以为报警图片等,服务端在获取到报警文件后先保存该报警文件,以供浏览器请求。
目前浏览器可以采用轮询的方式从服务端请求报警文件,即浏览器每间隔一段时间向服务端发送请求消息,服务端接收该请求消息,如果在当前已保存报警文件,向浏览器发送该报警文件的统一资源定位符(uniform resource locator,URL),浏览器通过该报警文件的URL获取到原始数据并解析成正常像素显示的报警文件;如果未保存报警文件,则通知浏览器。
发明人在实现本申请的过程中,发现上述方式至少存在如下缺陷:
浏览器采用轮询的方式从服务端请求报警文件来实现对报警文件的显示时,服务端需要向浏览器发送报警文件在服务端上可访问的URL以供浏览器根据URL显示报警文件,因此服务端需要保存报警文件,对服务端的存储资源浪费很大。
发明内容
本申请实施例提供了一种显示报警文件的方法、装置、系统、电子设备、计算机可读存储介质及计算机程序产品,以减小浪费服务端的存储资源。所述技术方案如下:
一方面,本申请提供了一种显示报警文件的方法,所述方法包括:
通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据包,其中所述服务端发送所述报警文件后释放所述报警文件占用的存储资源;
对所述报警文件对应的数据包解析得到所述报警文件;
生成所述报警文件的统一资源定位符URL;
根据所述报警文件的URL显示所述报警文件。
可选的,所述报警文件对应M个数据包,M为大于或等于1的整数,所述对所述报警文件对应的数据包解析得到所述报警文件,包括:
针对所述M个数据包中的每个数据包,从所述数据包的包头中读取校验字符串;
在所述校验字符串为预设校验字符串的情况下,从所述包头中读取包头长度;
根据所述包头长度,从所述包头中读取所述报警文件的文件长度、所述报警文件的文件标识和所述数据包的包序号;
在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中;
在所述存储结构中保存的属于所述报警文件的数据长度等于所述文件长度时,所述存储 结构保存的属于所述报警文件的数据为所述报警文件。
可选的,所述数据包的包头还包括所述数据包的净荷长度,
所述在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中,包括:
根据所述文件标识,确定所述数据包是否是接收的第一个属于所述报警文件的数据包;
如果是第一个,则创建所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,在所述存储结构中保存属于所述报警文件的数据长度,所述数据长度等于所述数据包的净荷长度;
如果不是第一个,则确定所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,将所述存储结构中保存的属于所述报警文件的数据长度和所述数据包的净荷长度进行累加,得到累加值,将所述存储结构中保存的所述数据长度替换为所述累加值。
可选的,所述解析得到的报警文件保存在内存中,所述生成所述报警文件的统一资源定位符URL,包括:
根据内存中保存的所述报警文件,通过用于生成统一资源定位符URL的应用程序接口API,生成所述报警文件的URL。
可选的,所述通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据包之前,还包括:
通过所述长连接向服务端发送订阅请求消息,所述订阅请求消息包括内容类型;
通过所述长连接接收所述报警文件对应的报警信息,所述报警文件的内容属于所述内容类型。
另一方面,本申请提供了一种显示报警文件的装置,所述装置包括:
接收模块,用于通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据包,其中所述服务端发送所述报警文件后释放所述报警文件占用的存储资源;
解析模块,用于对所述报警文件对应的数据包解析得到所述报警文件;
生成模块,用于生成所述报警文件的统一资源定位符URL;
显示模块,用于根据所述报警文件的URL显示所述报警文件。
可选的,所述报警文件对应M个数据包,M为大于或等于1的整数,所述解析模块,用于:
针对所述M个数据包中的每个数据包,从所述数据包的包头中读取校验字符串;
在所述校验字符串为预设校验字符串的情况下,从所述包头中读取包头长度;
根据所述包头长度,从所述包头中读取所述报警文件的文件长度、所述报警文件的文件标识和所述数据包的包序号;
在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中;
在所述存储结构中保存的属于所述报警文件的数据长度等于所述文件长度时,所述存储结构保存的属于所述报警文件的数据为所述报警文件。
可选的,所述数据包的包头还包括所述数据包的净荷长度,
所述解析模块,用于:
根据所述文件标识,确定所述数据包是否是接收的第一个属于所述报警文件的数据包;
如果是第一个,则创建所述文件标识对应的存储结构,在所述存储结构中将所述数据包 的净荷部分保存到所述包序号对应的存储空间中,在所述存储结构中保存属于所述报警文件的数据长度,所述数据长度等于所述数据包的净荷长度;
如果不是第一个,则确定所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,将所述存储结构中保存的属于所述报警文件的数据长度和所述数据包的净荷长度进行累加,得到累加值,将所述存储结构中保存的所述数据长度替换为所述累加值。
可选的,所述解析得到的报警文件保存在内存中,所述生成模块,用于:
根据内存中保存的所述报警文件,通过用于生成统一资源定位符URL的应用程序接口API,生成所述报警文件的URL。
可选的,所述装置还包括:发送模块,
所述发送模块,用于通过所述长连接向服务端发送订阅请求消息,所述订阅请求消息包括内容类型;
所述接收模块,还用于通过所述长连接接收所述报警文件对应的报警信息,所述报警文件的内容属于所述内容类型。
另一方面,本申请提供了一种显示报警文件的系统,所述系统包括:客户端和服务端;
所述服务端,用于通过与所述客户端之间的长连接向所述客户端发送报警文件对应的数据包,释放所述报警文件占用的存储资源;
所述客户端,用于通过与所述服务端之间的长连接接收所述报警文件对应的数据包;对所述报警文件对应的数据包解析得到所述报警文件;生成所述报警文件的统一资源定位符URL;根据所述报警文件的URL显示所述报警文件。
可选的,所述报警文件对应M个数据包,M为大于或等于1的整数,所述客户端,用于:
针对所述M个数据包中的每个数据包,从所述数据包的包头中读取校验字符串;
在所述校验字符串为预设校验字符串的情况下,从所述包头中读取包头长度;
根据所述包头长度,从所述包头中读取所述报警文件的文件长度、所述报警文件的文件标识和所述数据包的包序号;
在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中;
在所述存储结构中保存的属于所述报警文件的数据长度等于所述文件长度时,所述存储结构保存的属于所述报警文件的数据为所述报警文件。
可选的,所述数据包的包头还包括所述数据包的净荷长度,
所述客户端,用于:
根据所述文件标识,确定所述数据包是否是接收的第一个属于所述报警文件的数据包;
如果是第一个,则创建所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,在所述存储结构中保存属于所述报警文件的数据长度,所述数据长度等于所述数据包的净荷长度;
如果不是第一个,则确定所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,将所述存储结构中保存的属于所述报警文件的数据长度和所述数据包的净荷长度进行累加,得到累加值,将所述存储结构中保存的所述数据长度替换为所述累加值。
可选的,所述客户端,用于将解析得到的报警文件保存在内存中,根据所述内存中保存的所述报警文件,通过用于生成统一资源定位符URL的应用程序接口API,生成所述报警文 件的URL。
可选的,所述客户端,还用于通过所述长连接向服务端发送订阅请求消息,所述订阅请求消息包括内容类型;通过所述长连接接收所述报警文件对应的报警信息,所述报警文件的内容属于所述内容类型;
所述服务端,还用于通过所述长连接向所述客户端发送所述报警文件对应的报警信息。
另一方面,本申请实施例提供了一种电子设备,包括至少一个处理器和至少一个存储器,所述至少一个存储器用于存储至少一个指令,所述至少一个指令被所述至少一个处理器加载并运行,以实现上述显示报警文件的方法。
另一方面,本申请实施例提供了一种计算机可读存储介质,用于存储至少一个指令,所述至少一个指令被处理器加载并运行,以实现上述显示报警文件的方法。
另一方面,本申请实施例提供了一种计算机程序产品,所述计算机程序产品包括在计算机可读存储介质中存储的计算机程序,并且所述计算程序通过处理器进行加载来实现上述显示报警文件的方法。
本申请实施例提供的技术方案可以包括以下有益效果:
客户端显示报警文件时需要基于报警文件的URL,由于客户端通过长连接接收报警文件的数据包,从报警文件的数据包解析出报警文件,生成报警文件的URL,这样客户端就可以基于生成的URL显示报警文件,如此服务端在获取到报警文件后,就可以向客户端发送报警文件,不需要保存报警文件,提高了推送报警文件的实时性。如果客户端采用轮询的方式,需要服务端先保存获取报警文件,这样客户端轮询服务端时才能得到报警文件的URL,再根据该URL从服务端获取并显示报警文件。相比轮询方式,服务端不保存报警文件,在向客户端推送报警文件后就可以释放存储资源,减小对服务端的存储资源的占用,还避免了轮询导致大量消耗服务端的资源和带宽资源。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。
图1是本申请实施例提供的一种系统架构示意图;
图2是本申请实施例提供的另一种系统架构示意图;
图3是本申请实施例提供的获取报警文件的方法流程图;
图4是本申请实施例提供的一种报警文件的示意图;
图5是本申请实施例提供的一种数据包的结构示意图;
图6是本申请实施例提供的另一种数据包的结构示意图;
图7是本申请实施例提供的再一种数据包的结构示意图;
图8是本申请实施例提供的一种显示报警文件的方法流程图;
图9是本申请实施例提供的另一种显示报警文件的方法流程图;
图10是本申请实施例提供的一种显示报警文件的装置结构示意图;
图11是本申请实施例提供的一种电子设备结构示意图。
通过上述附图,已示出本申请明确的实施例,后文中将有更详细的描述。这些附图和文字描述并不是为了通过任何方式限制本申请构思的范围,而是通过参考特定实施例为本领域技术人员说明本申请的概念。
具体实施方式
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。
参见图1,本申请实施例提供了一种显示报警文件的系统,该系统包括:
服务端1和客户端2,客户端2可以建立与服务端1之间的长连接。作为一种示例,该长连接可以为Websocket连接,Websocket连接是一条全双工的双向通信连接。
作为一种示例,客户端2可以为浏览器或其他应用。
服务端1可以获取报警文件。报警文件的文件类型可以为图片文件、视频文件或文本文件等。
可选的,服务端1可以为网络硬盘录像机(Network Video Recorder,NVR)或网络摄像头(IP CAMERA,IPC)等。服务端1自身获取到报警文件,例如自身可以拍摄得到报警文件。
服务端1也可以为服务器,参见图2,服务端1还与至少一个监控摄像机3之间建立有连接。
对于每个监控摄像机3,该监控摄像机3可以向服务端1发送报警信息,紧随报警信息之后向服务端1发送至少一个报警文件。
该报警信息可以包括待发送的报警文件的文件数目、各报警文件的文件描述信息和该监控摄像机3的设备信息等至少一个。
报警文件的文件描述信息可以包括该报警文件的文件内容描述信息。例如,假设该报警文件是图片文件,该文件内容描述信息用于描述该图片文件的内容,该文件内容描述信息可以包括该图片文件是背景图还是前景图,和/或该图片文件中图像是否为特定对象的图像,在为特定对象图像的情况下,该文件内容描述信息还可以包括该特定对象图像对应的对象的特征信息,例如年龄特征、身高特征等特征中的至少一个。
该监控摄像机3的设备信息可以包括该监控摄像机3的地址。该地址可以包括互联网协议地址(Internet Protocol Address,IP)地址或媒体访问控制地址(Media Access Control Address,MAC)地址中的至少一个。
参见图3,客户端2建立与服务端1之间的长连接(可以为Websocket连接)后,可以通过该长连接向服务端1发送订阅请求消息,该订阅请求消息包括内容类型,用于在服务端1中订阅文件内容属于该内容类型的报警文件。
内容类型可以包括特定对象图像等,例如,假设特定对象是车辆,则内容类型可以为车辆图像,假设该订阅请求消息包括的内容类型为车辆图像,即在服务端1中订阅文件内容属于车辆图像的报警文件,也就是说服务端1在获取到属于车辆图像的报警文件时,向客户端2发送该报警文件。
服务端1接收该订阅请求消息,保存该订阅请求消息包括的内容类型。这样参见图4,当服务端1获取到信息内容属于该内容类型的报警信息时通过该长连接向客户端2发送该报警信息,以及当服务端1获取到文件内容属于该内容类型的报警文件时,将该报警文件封装成M个数据包,M为大于或等于1的整数,针对每个封装后的数据包,服务端1通过该长连接向客户端2发送该数据包,且在发送该数据包后,释放该数据包占用的存储资源。服务端也可以在发送报警文件对应的M个数据包后,释放该报警文件占用的存储资源。
可选的,服务端释放该报警文件占用的存储资源包括释放该报警文件占用的全部资源或占用的部分资源。服务端发送报警文件后释放该报警文件占用的存储资源可以是:服务端发送报警文件的全部后释放该报警文件占用的全部或部分资源;或者,服务端发送报警文件的部分后释放该报警文件占用的部分资源。在实现时,服务端发送M个数据包后释放该M个数据包占用的存储资源,或者,服务端也可以在发送报警文件的X个数据包后,释放该X个数据包中Y个数据包占用的存储资源,其中X小于或等于M,Y小于或等于X。
可选的,在每封装成一个数据包时,服务端1通过该长连接向客户端2发送该数据包。
客户端2可以解析接收的数据包得到报警文件,生成报警文件的URL,根据该报警文件的URL显示该报警文件。客户端2或服务端1也可以主动请求断开该长连接。
数据包包括包头和位于包头之后的净荷部分,净荷部分包括该报警文件或该报警文件中的部分内容。参见图5,包头可以包括校验字段,包头长度字段、文件长度字段、文件标识字段和包序号字段。校验字段用于携带预设校验字符串,包头长度字段用于携带该数据包的包头长度,文件长度字段用于携带该报警文件的文件长度,文件标识字段用于携带报警文件的文件标识,包序号字段用于携带该数据包的包序号。
对于校验字段,包头长度字段、文件长度字段、文件标识字段和包序号字段等字段。这些字段在包头中的排列顺序有多种。在本申请中列举了一种排列顺序的示例进行说明,对于其他的排列顺序不再一一列举。
该示例为,参见图5,校验字段的长度为a个字节,a为大于1的整数,校验字段为包头的第0至a-1个字节;包头长度字段的长度为b个字节,b为大于1的整数,包头长度字段为包头的第a至a+b-1个字节;文件长度字段的长度为c个字节,c为大于1的整数,文件长度字段为包头的第a+b至a+b+c-1个字节;文件标识字段的长度为d个字节,d为大于1的整数,文件标识字段为包头的第a+b+c至a+b+c+d-1个字节;以及包序号字段的长度为e个字节,e为大于1的整数,包序号字段为包头的第a+b+c+d至a+b+c+d+e-1个字节。
参见图6,该数据包的包头中还可以包括净荷长度字段,该净荷长度字段可以用于携带该数据包的净荷部分的长度。该净荷长度字段可以位于文件长度字段和文件标识字段之间。净荷长度字段的长度为f个字节,f为大于1的整数,净荷长度字段为包头的第a+b+c至a+b+c+f-1个字节,相应地,文件标识字段为包头的第a+b+c+f至a+b+c+d+f-1个字节,包序号字段为包头的第a+b+c+d+f至a+b+c+d+f+e-1个字节。
参见图6,该数据包的包头中还可以包括文件类型字段,该文件类型字段可以用于携带该报警文件的文件类型。该文件类型字段可以位于包序号字段之后。文件类型字段的长度为g个字节,g为大于1的整数,文件类型字段为包头的第a+b+c+d+f+e至a+b+c+d+f+e+g-1个字节。
例如,参见图7,假设a为4、b为4、c为4,f为4,d为32,e为4,g为4。也就是说,校验字段为包头的第0至3个字节、包头长度字段为包头的第4至7个字节、文件长度字段为包头的第8至11个字节、净荷长度字段为包头的第12至15个字节、文件标识字段为包头的第16至47个字节、包序号字段为包头的第48至51个字节、文件类型字段为包头的 第52至55个字节。
对于图6所示的数据包的包头可以定义成如下结构形式:
typedef struct_INTER_HEADER_BINARY_
{
unsigned char byMagic[4];//byMagic为校验字段,用作做容错,固定为byMagic[4]={H,E,A,D},H,E,A,D为预设的检验字符串;
unsigned int dwHeaderLen;//dwHeaderLen为包头长度字段,仅指INTER_HEADER_BINARY的长度,用于后续HEADER的扩展;
unsigned int dwDataLen;//dwDataLen为文件长度字段,仅指文件数据总长度(不包含INTER_HEADER_BINARY);
unsigned int dwSingleDataLen;//dwSingleDataLen为净荷长度字段,仅指数据量较大的报警文件被分包后单个数据包的净荷部分的长度(不包含INTER_HEADER_BINARY),如果报警文件没有被分包发送,则dwSingleDataLen==dwDataLen;
unsigned char szpId[32];//szpId文件标识字段,为表示对应结构化信息中报警文件的文件标识,实现结构化信息和二进制图片的关联;
unsigned int dwIndex;//dwIndex为包序号字段,该数据包在分包后包索引,指明是第几包数据;
unsigned char byDataType;//byDataType为文件类型字段,0可以表示jpeg图片数据的文件类型;
unsigned char byRes[2];为保留字段
}INTER_HEADER_BINARY,*LPINTER_HEADER_BINARY;
客户端2通过该长连接接收服务端1发送的该M个数据包;通过对该M个数据包的每个数据包的包头进行解析,得到该报警文件。
参见图8,本申请实施例提供了一种显示报警文件的方法,所述方法包括:
步骤101:通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据包,其中所述服务端发送所述报警文件后释放所述报警文件占用的存储资源。
步骤102:对所述报警文件对应的数据包解析得到所述报警文件。
步骤103:生成所述报警文件的统一资源定位符URL。
步骤104:根据所述报警文件的URL显示所述报警文件。
在本申请实施例中,由于与服务器之间存在长连接,这样可以通过长连接接收服务端的报警文件对应的数据包,对报警文件对应的数据包进行解析得到报警文件,生成该报警文件的URL,这样根据该报警文件的URL显示该报警文件。如此不需要采用轮询方式请求报警文件,服务端在得到报警文件就可以推送给客户端,可以不保存报警文件,从而在推送报警文件后就可释放报警文件占用的存储资源,减小对服务端的存储资源的占用,还避免了轮询导致大量消耗服务端的资源和带宽资源,提高推送报警文件的实时性。由于生成该报警文件的URL,根据该URL可以自动显示该报警文件。
参见图9,本申请实施例提供了另一种显示报警文件的方法,所述方法包括:
步骤201:客户端建立与服务端之间的长连接,通过该长连接向服务端发送订阅请求消息,该订阅请求消息包括内容类型。
该长连接可以为Websocket连接,内容类型可以包括特定对象图像。例如假设特定对象图像是车辆图像等,即内容类型中可以为车辆图像。
步骤202:服务端接收该订阅请求消息,该订阅请求消息携带该内容类型,当服务端获取到信息内容属于该内容类型的报警信息时,通过该长连接向客户端发送该报警信息。
服务端接收到该订阅请求消息后,保存该订阅请求消息包括的内容类型。这样当服务端获取到信息内容属于该内容类型的报警信息时,通过该长连接向客户端发送该报警信息。
步骤203:客户端接收该报警信息。
客户端可以显示报警信息,由于报警信息包括各报警文件的文件描述信息和监控摄像机的设备信息等内容,可以让用户了解报警文件的情况等信息。
步骤204:服务端当获取到文件内容属于该内容类型的报警文件时,将该报警文件封装成M个数据包。
其中,步骤202和步骤204之间可以没有先后关系,即可以服务端可以先发送报警信息,再封装数据包;或者,先封装数据包,再发送报警信息;或者,同时进行封装数据包和发送报警信息。
在服务端获取到属于该内容类型的报警信息后,服务端还获取到文件内容属于该内容类型的报警文件,将该报警文件封装成M个数据包。
对于每个数据包,该数据包可以包括包头和净荷部分,包头位于净荷部分之前。参见图5,包头可以包括校验字段,包头长度字段、文件长度字段、文件标识字段和包序号字段。校验字段用于携带预设校验字符串,包头长度字段用于携带该数据包的包头长度,文件长度字段用于携带该报警文件的文件长度,文件标识字段用于携带报警文件的文件标识,包序号字段用于携带该数据包的包序号。
可选的,参见图6,该数据包的包头中还可以包括净荷长度字段,该净荷长度字段可以用于携带该数据包的净荷部分的长度。该净荷长度字段可以位于文件长度字段和文件标识字段之间。
可选的,参见图6,该数据包的包头中还可以包括文件类型字段,该文件类型字段可以用于携带该报警文件的文件类型。
步骤205:服务端通过该长连接向客户端发送该M个数据包,释放该M个数据包占用的存储资源。
对于该M个数据包,服务端在该长连接上每次向客户端发送一个数据包。
服务端还可以获取到文件内容属于该内容类型的报警文件,通过上述204或205的流程将该报警文件封装成至少一个数据包,并通过该长连接向客户端发送该至少一个数据包。从而实现服务端接收到文件内容属于订阅的内容类型的报警文件时,就可以向客户端发送,可以不需要存储该报警文件,这样不需要轮询服务端,提高了获取报警文件的实时性,避免浪费服务端的资源(例如该资源可以包括存储资源)和带宽资源。
服务端可以在发送该M个数据包后,释放该M个数据包占用的存储资源,或者,释放该M个数据包中的部分数据包占用的存储资源,以实现释放该存储文件占用的存储资源;也可以在发送报警文件的X个数据包后,释放该X个数据包中Y个数据包占用的存储资源,其中X小于等于M,Y小于等于X;较优地,可以在每发送一个数据包后,释放该数据包占用的存储资源,从而减少对服务端存储资源的占用。
步骤206:客户端接收数据包,从该数据包的包头中读取校验字符串,在校验字符串为 预设校验字符串时,从该包头中读取包头长度。
服务端需要一段时间才能发送完该M个数据包,在该段时间段,该M个数据包中的最先发送的部分数据包可能被传输到客户端,客户端接收数据包。
在本步骤中客户端接收的数据包是该M个数据包中的任意一个,客户端接收的数据包可能是该报警文件的第一个数据包,也可能是该报警文件的最后一个数据包,也可能是位于第一个数据包和最后一个数据包之间的任一个数据包。
参见图5,校验字段是数据包的包头中的第一个字段,其长度为a个字节,第二个字段为包头长度字段,其长度为b个字节。
在本步骤中,该数据包的包头中读取前a个字节的信息得到检验字符串,在校验字符串为预设校验字符串时,从该数据包的包头中读取第a至a+b-1个字节的信息,得到包头长度。
步骤207:客户端根据该包头长度,从包头中读取报警文件的文件长度、报警文件的文件标识和该数据包的包序号。
客户端根据该包头长度,可以确定该数据包的包头剩余部分和净荷部分,并从该数据包中读取包头剩余部分。
参见图5,位于包头长度字段之后的字段为文件长度字段,文件长度字段的长度为c个字节。也就是说包头剩余部分的第一个字段为文件长度字段,从该包头剩余部分中读取第0至c-1个字节的信息,得到该报警文件的文件长度。
参见图5,位于文件长度字段之后的字段为文件标识字段,文件标识字段的长度为d个字节。这样从该包头剩余部分中读取第c至c+d-1个字节的信息,得到该报警文件的文件标识。
参见图5,位于文件标识字段之后的字段为包序号字段,包序号字段的长度为e个字节。这样从该包头剩余部分中读取第c+d至c+d+e-1个字节的信息,得到该数据包的包序号。
可选的,参见图5,该数据包的包头中还可以包括净荷长度字段,该净荷长度字段可以用于携带该数据包的净荷部分的长度。该净荷长度字段可以位于文件长度字段和文件标识字段之间。该净荷长度字段的长度为f个字节。
在图5所示的数据包的包头中,从该包头剩余部分中读取第0至c-1个字节的信息,得到该报警文件的文件长度。从该包头剩余部分中读取第c至c+f-1个字节的信息,得到该数据包的净荷部分的长度。从该包头剩余部分中读取第c+f至c+f+d-1个字节的信息,得到该报警文件的文件标识。以及,从该包头剩余部分中读取第c+f+d至c+f+d+e-1个字节的信息,得到该数据包的包序号。
可选的,参见图5,该数据包的包头中还可以包括文件类型字段,该文件类型字段可以用于携带该报警文件的文件类型。该文件类型字段可以位于包序号字段之后。该文件类型字段的长度为g个字节。
在图5所示的数据包的包头中,从该包头剩余部分中读取第c+f+d+e至c+f+d+e+g-1个字节的信息,得到该报警文件的文件类型。
步骤208:客户端在该文件标识对应的存储结构中,将该数据包的净荷部分保存在该包序号对应的存储空间中。
在客户端接收到报警文件的数据包的过程中,使用一个存储结构来缓存已接收的属于该报警文件的各数据包的净荷部分。该存储结构与该报警文件的文件标识相对应,该存储结构包括至少一个存储空间,属于该报警文件的每个数据包对应一个存储空间,且每个数据包对应的存储空间不同。
客户端可以为浏览器,该存储结构可以位于浏览器内存中。
可选的,该存储结构可以为数组。
在本步骤中,根据该报警文件的文件标识,确定该数据包是否是接收的第一个属于该报警文件的数据包;如果是第一个,则创建该文件标识对应的存储结构,在该存储结构中将该数据包的净荷部分保存到该包序号对应的存储空间中;如果不是第一个,则确定该文件标识对应的存储结构,在该存储结构中将该数据包的净荷部分保存到该包序号对应的存储空间中。
可选的,将该数据包的净荷部分保存到该包序号对应的存储空间中之前,还可以比较净荷长度字段中携带的该数据包的净荷长度与该数据的净荷部分的实际长度是否相等。如果相等,则表明该数据的净荷部分没有发生数据丢失,将该数据包的净荷部分保存到该包序号对应的存储空间。如果不相等,则表明该数据包的净荷部分发生数据丢失,丢弃该存储结构保存的该报警文件的数据。
可选的,服务端在发送报警文件的数据包之后也可以不立即释放该报警文件占用的存储资源,这样如果客户端丢弃该存储结构保存的该报警文件的数据,客户端可以请求服务端发送该报警文件包括的数据包。其中,客户端在接收完该报警文件包括的数据包后,可以通知服务端,服务端接收该通知后,释放该报警文件占用的存储资源。
可选的,如果该数据包的净荷部分发生数据丢失,也可以将该数据包的净荷部分保存到该包序号对应的存储空间,这样显示出的报警文件可能存在部分内容缺失。例如,假设报警文件为图片,则显示的图片中存在部分内容缺失。
其中,包序号可以从1开始顺序编号,包序号1对应该存储结构中的第一个存储空间,包序号2对应该数据组中的第二个存储空间,以此类推,对于其他包序号不再一一说明。
参见图6,该数据包的包头还包括该数据包的净荷长度,该存储结构还保存有属于该报警文件的数据长度,具体地,可以是在接收到第一个属于该报警文件的数据包的情况下,在该存储结构中保存属于该报警文件的数据长度,所述数据长度等于所述第一个数据包的净荷长度;在接收到的属于该报警文件的数据包不是第一个属于该报警文件的数据包的情况下,在将该数据包的净荷部分保存在该包序号对应的存储空间中之后,还可以将存储结构中保存的属于该报警文件的数据长度和该数据包的净荷长度进行累加,得到累加值,将该存储结构中保存的属于该报警文件的数据长度替换为该累加值。
在本步骤中,在将该存储结构中保存的属于该报警文件的数据长度替换为该累加值之后,还判断该存储结构中保存的该报警文件的数据长度是否等于报警文件的文件长度,如果等于,则执行步骤209,如果不等于,则客户端当接收到数据包时重新执行206至208的操作。
步骤209:客户端在该存储结构中保存的属于该报警文件的数据长度等于该报警文件的文件长度时,该存储结构保存的属于该报警文件的数据为该报警文件,生成该报警文件的URL。
客户端提供用于生成URL的应用程序编程接口(Application Programming Interface,API)。客户端可以调用该API,将该存储结构中保存的该报警文件输入到该API,通过该API生成该报警文件的URL。
可选的,可以在报警文件的文件类型为图片或视频时,生成该报警文件的URL。
可选的,该URL可以是报警文件的临时URL。
可选的,客户端得到报警文件后,可以将报警文件保存在客户端的内存中,并统计客户端的内存中保存的报警文件数目,在该报警文件数目达到预设数目阈值,则从客户端的内存中删除最早保存的报警文件。这样可以避免客户端的内存被无限制占用,得不到有效释放。
可选的,可以设置管理存储结构,该管理存储结构包括的存储空间数目为预设数目阈值。在生成报警文件的URL时,若管理存储结构中还存在空闲的存储空间,将当前时间作为生成 的报警文件的保存时间,将该生成的报警文件的URL和该保存时间保存到管理存储结构的一个空闲存储空间;若该管理存储结构中没有空闲的存储空间,从该管理存储结构中找出保存时间最早的报警文件的URL,从客户端的内存中删除所述保存时间最早的URL对应的报警文件,清空所述保存时间最早的URL所在的存储空间,将该生成的报警文件的URL和保存时间保存到该清空的存储空间。
可选的,管理存储结构为数组等。
步骤210:客户端根据该报警文件的URL显示该报警文件。
在客户端为浏览器时,由于浏览器是基于图片或视频的URL进行显示的,为了不对浏览器已有的逻辑进行修改,所以通过用于生成URL的API生成该报警文件的URL,这样浏览器根据该URL可以自动显示该报警文件。
可选的,在报警文件为文本文件时,浏览器也可以不用生成文本文件的URL,可以直接显示文本文件。
可选的,对于客户端与服务端之间的长连接,可以由客户端主动断开,或由服务端主动断开。
在本申请实施例中,由于客户端显示报警文件需要基于报警文件的URL,通过客户端建立与服务器之间的长连接,向服务端发送该订阅请求消息,这样在服务端在接收到文件内容属于该内容类型的报警文件时发送M个数据包,从该M个数据包解析出报警文件,生成报警文件的URL,这样客户端就可以基于生成的URL显示报警文件,从而提高发送报警文件的效率,也避免了轮询导致大量消耗服务端的资源和带宽资源。相较于轮询去取服务端中报警文件对应URL,服务端由于存储空间受限,一旦报警文件较多时服务端后面获取的报警文件会覆盖前面获取的报警文件,但如果在覆盖时客户端还未轮询到,那被覆盖的报警文件就不能推送到客户端显示,从而导致显示报警文件不可靠。而在本方案中可以将每个报警文件都可以推送显示,提高显示报警文件可靠性。相较于在服务端存储报警文件,客户端轮询去取URL的方式,由于本方案在客户端的内存中存储报警文件并生成报警文件对应的URL,服务端就不用存储报警文件,在推送报警文件后就可释放报警文件占用的存储资源,减少了服务端存储空间的占用。另外,数据包的包头中包括校验字段,包头长度字段、文件长度字段、文件标识字段和包序号字段。校验字段用于携带预设校验字符串,包头长度字段用于携带该数据包的包头长度,文件长度字段用于携带该报警文件的文件长度,文件标识字段用于携带报警文件的文件标识,包序号字段用于携带该数据包的包序号。这样基于包头中的各字段,可以成功识别出属于一个报警文件的M个数据包,并解析出报警文件。
下述为本申请装置实施例,可以用于执行本申请方法实施例。对于本申请装置实施例中未披露的细节,请参照本申请方法实施例。
参见图10,本申请实施例提供了一种显示报警文件的装置300,所述装置300包括:
接收模块301,用于通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据包,其中所述服务端发送所述报警文件后释放所述报警文件占用的存储资源;
解析模块302,用于对所述报警文件对应的数据包解析得到所述报警文件;
生成模块303,用于生成所述报警文件的统一资源定位符URL;
显示模块304,用于根据所述报警文件的URL显示所述报警文件。
可选的,所述报警文件对应M个数据包,M为大于或等于1的整数,所述解析模块302,用于:
针对所述M个数据包中的每个数据包,从所述数据包的包头中读取校验字符串;
在所述校验字符串为预设校验字符串的情况下,从所述包头中读取包头长度;
根据所述包头长度,从所述包头中读取所述报警文件的文件长度、所述报警文件的文件标识和所述数据包的包序号;
在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中;
在所述存储结构中保存的属于所述报警文件的数据长度等于所述文件长度时,将所述存储结构保存的属于所述报警文件的数据为所述报警文件。
可选的,所述数据包的包头还包括所述数据包的净荷长度,
所述解析模块302,用于:
根据所述文件标识,确定所述数据包是否是接收的第一个属于所述报警文件的数据包;
如果是第一个,则创建所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,在所述存储结构中保存属于所述报警文件的数据长度,所述数据长度等于所述数据包的净荷长度;
如果不是第一个,则确定所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,将所述存储结构中保存的属于所述报警文件的数据长度和所述数据包的净荷长度进行累加,得到累加值,将所述存储结构中保存的所述数据长度替换为所述累加值。
可选的,所述解析得到的报警文件保存在内存中,所述生成模块303,用于:
根据内存中保存的所述报警文件,通过用于生成统一资源定位符URL的应用程序接口API,生成所述报警文件的URL。
可选的,所述装置300还包括:发送模块,
所述发送模块,用于通过所述长连接向服务端发送订阅请求消息,所述订阅请求消息包括内容类型;
所述接收模块,还用于通过所述长连接接收所述报警文件对应的报警信息,所述报警文件的内容属于所述内容类型。
在本申请实施例中,显示模块显示报警文件时需要基于报警文件的URL,由于与服务器之间存在的长连接,这样接收模块可以通过长连接接收服务端的报警文件对应的数据包,解析模块对报警文件对应的数据包进行解析得到报警文件,生成模块通过用于生成URL的API生成的该报警文件的URL,显示模块根据该URL可以自动显示该报警文件,如此服务端在获取到报警文件后,就可以向该装置发送报警文件,不需要保存报警文件,在推送报警文件后就可释放报警文件占用的存储资源,提高了推送报警文件的实时性,减小对服务端的存储资源的占用,还避免了轮询导致大量消耗服务端的资源和带宽资源。
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。
图11示出了本申请一个示例性实施例提供的电子设备400的结构框图。该电子设备400中可以运行上述客户端,可以是便携式移动终端,比如:智能手机、平板电脑、笔记本电脑或台式电脑。电子设备400还可能被称为用户设备、便携式终端、膝上型终端、台式终端等其他名称。
通常,电子设备400包括有:处理器401和存储器402。
处理器401可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理 器401可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器401也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central Processing Unit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器401可以在集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器401还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。
存储器402可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器402还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器402中的非暂态的计算机可读存储介质用于存储至少一个指令,该至少一个指令用于被处理器401所执行以实现本申请中方法实施例提供的显示报警文件的方法。
在一些实施例中,电子设备400还可选包括有:外围设备接口403和至少一个外围设备。处理器401、存储器402和外围设备接口403之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口403相连。具体地,外围设备包括:射频电路404、触摸显示屏405、摄像头406、音频电路407、定位组件408和电源409中的至少一种。
外围设备接口403可被用于将I/O(Input/Output,输入/输出)相关的至少一个外围设备连接到处理器401和存储器402。在一些实施例中,处理器401、存储器402和外围设备接口403被集成在同一芯片或电路板上;在一些其他实施例中,处理器401、存储器402和外围设备接口403中的任意一个或两个可以在单独的芯片或电路板上实现,本实施例对此不加以限定。
射频电路404用于接收和发射RF(Radio Frequency,射频)信号,也称电磁信号。射频电路404通过电磁信号与通信网络以及其他通信设备进行通信。射频电路404将电信号转换为电磁信号进行发送,或者,将接收到的电磁信号转换为电信号。可选地,射频电路404包括:天线系统、RF收发器、一个或多个放大器、调谐器、振荡器、数字信号处理器、编解码芯片组、用户身份模块卡等等。射频电路404可以通过至少一种无线通信协议来与其它终端进行通信。该无线通信协议包括但不限于:万维网、城域网、内联网、各代移动通信网络(2G、3G、4G及5G)、无线局域网和/或WiFi(Wireless Fidelity,无线保真)网络。在一些实施例中,射频电路404还可以包括NFC(Near Field Communication,近距离无线通信)有关的电路,本申请对此不加以限定。
显示屏405用于显示UI(User Interface,用户界面)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏405是触摸显示屏时,显示屏405还具有采集在显示屏405的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器401进行处理。此时,显示屏405还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在一些实施例中,显示屏405可以为一个,设置电子设备400的前面板;在另一些实施例中,显示屏405可以为至少两个,分别设置在电子设备400的不同表面或呈折叠设计;在再一些实施例中,显示屏405可以是柔性显示屏,设置在电子设备400的弯曲表面上或折叠面上。甚至,显示屏405还可以设置成非矩形的不规则图形,也即异形屏。显示屏405可以采用LCD(Liquid Crystal Display,液晶显示屏)、OLED(Organic Light-Emitting Diode,有机发光二极管)等材质制备。
摄像头组件406用于采集图像或视频。可选地,摄像头组件406包括前置摄像头和后置摄像头。通常,前置摄像头设置在电子设备400的前面板,后置摄像头设置在电子设备400的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及VR(Virtual Reality,虚拟现实)拍摄功能或者其它融合拍摄功能。在一些实施例中,摄像头组件406还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。
音频电路407可以包括麦克风和扬声器。麦克风用于采集用户及环境的声波,并将声波转换为电信号输入至处理器401进行处理,或者输入至射频电路404以实现语音通信。出于立体声采集或降噪的目的,麦克风可以为多个,分别设置在电子设备400的不同部位。麦克风还可以是阵列麦克风或全向采集型麦克风。扬声器则用于将来自处理器401或射频电路404的电信号转换为声波。扬声器可以是传统的薄膜扬声器,也可以是压电陶瓷扬声器。当扬声器是压电陶瓷扬声器时,不仅可以将电信号转换为人类可听见的声波,也可以将电信号转换为人类听不见的声波以进行测距等用途。在一些实施例中,音频电路407还可以包括耳机插孔。
定位组件408用于定位电子设备400的当前地理位置,以实现导航或LBS(Location Based Service,基于位置的服务)。定位组件408可以是基于美国的GPS(Global Positioning System,全球定位系统)、中国的北斗系统或俄罗斯的伽利略系统的定位组件。
电源409用于为电子设备400中的各个组件进行供电。电源409可以是交流电、直流电、一次性电池或可充电电池。当电源409包括可充电电池时,该可充电电池可以是有线充电电池或无线充电电池。有线充电电池是通过有线线路充电的电池,无线充电电池是通过无线线圈充电的电池。该可充电电池还可以用于支持快充技术。
在一些实施例中,电子设备400还包括有一个或多个传感器410。该一个或多个传感器410包括但不限于:加速度传感器411、陀螺仪传感器412、压力传感器413、指纹传感器414、光学传感器415以及接近传感器416。
加速度传感器411可以检测以电子设备400建立的坐标系的三个坐标轴上的加速度大小。比如,加速度传感器411可以用于检测重力加速度在三个坐标轴上的分量。处理器401可以根据加速度传感器411采集的重力加速度信号,控制触摸显示屏405以横向视图或纵向视图进行用户界面的显示。加速度传感器411还可以用于游戏或者用户的运动数据的采集。
陀螺仪传感器412可以检测电子设备400的机体方向及转动角度,陀螺仪传感器412可以与加速度传感器411协同采集用户对电子设备400的3D动作。处理器401根据陀螺仪传感器412采集的数据,可以实现如下功能:动作感应(比如根据用户的倾斜操作来改变UI)、拍摄时的图像稳定、游戏控制以及惯性导航。
压力传感器413可以设置在电子设备400的侧边框和/或触摸显示屏405的下层。当压力传感器413设置在电子设备400的侧边框时,可以检测用户对电子设备400的握持信号,由处理器401根据压力传感器413采集的握持信号进行左右手识别或快捷操作。当压力传感器413设置在触摸显示屏405的下层时,由处理器401根据用户对触摸显示屏405的压力操作,实现对UI界面上的可操作性控件进行控制。可操作性控件包括按钮控件、滚动条控件、图标控件、菜单控件中的至少一种。
指纹传感器414用于采集用户的指纹,由处理器401根据指纹传感器414采集到的指纹识别用户的身份,或者,由指纹传感器414根据采集到的指纹识别用户的身份。在识别出用 户的身份为可信身份时,由处理器401授权该用户执行相关的敏感操作,该敏感操作包括解锁屏幕、查看加密信息、下载软件、支付及更改设置等。指纹传感器414可以被设置电子设备400的正面、背面或侧面。当电子设备400上设置有物理按键或厂商Logo时,指纹传感器414可以与物理按键或厂商Logo集成在一起。
光学传感器415用于采集环境光强度。在一个实施例中,处理器401可以根据光学传感器415采集的环境光强度,控制触摸显示屏405的显示亮度。具体地,当环境光强度较高时,调高触摸显示屏405的显示亮度;当环境光强度较低时,调低触摸显示屏405的显示亮度。在另一个实施例中,处理器401还可以根据光学传感器415采集的环境光强度,动态调整摄像头组件406的拍摄参数。
接近传感器416,也称距离传感器,通常设置在电子设备400的前面板。接近传感器416用于采集用户与电子设备400的正面之间的距离。在一个实施例中,当接近传感器416检测到用户与电子设备400的正面之间的距离逐渐变小时,由处理器401控制触摸显示屏405从亮屏状态切换为息屏状态;当接近传感器416检测到用户与电子设备400的正面之间的距离逐渐变大时,由处理器401控制触摸显示屏405从息屏状态切换为亮屏状态。
本领域技术人员可以理解,图11中示出的结构并不构成对电子设备400的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。
在本公开实施例中,由于与服务端之间存在的长连接,这样可以通过长连接接收服务端的报警文件对应的数据包,处理器对报警文件对应的数据包进行解析得到报警文件,生成该报警文件的URL,这样根据该报警文件的URL在显示屏中显示该报警文件。如此处理器不需要采用轮询方式请求报警文件,服务端在得到报警文件就可以推送给电子设备,可以不保存报警文件,从而在推送报警文件后就可释放报警文件占用的存储资源,减小对服务端的存储资源的占用,还避免了轮询导致大量消耗服务端的资源和带宽资源,提高推送报警文件的实时性。由于处理器生成该报警文件的URL,根据该URL可以自动显示该报警文件。
在示例性实施例中,本公开还提供了一种计算机可读存储介质,所述存储介质中存储有代码指令,所述代码指令由处理器执行,以执行上述实施例提供的显示报警文件的方法。例如,所述非易失性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
在本公开实施例中,由于处理器通过长连接接收服务端的报警文件对应的数据包,对报警文件对应的数据包进行解析得到报警文件,生成该报警文件的URL,这样根据该报警文件的URL显示该报警文件。如此处理器不需要采用轮询方式请求报警文件,这样服务端可以不保存报警文件,从而在推送报警文件后就可释放报警文件占用的存储资源,减小对服务端的存储资源的占用,还避免了轮询导致大量消耗服务端的资源和带宽资源,提高推送报警文件的实时性。由于处理器生成该报警文件的URL,根据该URL可以自动显示该报警文件。
在示例性实施例中,本公开还提供了一种计算机程序产品,所述计算机程序产品包括在计算机可读存储介质中存储的计算机程序,并且所述计算程序通过处理器进行加载来实现上述实施例提供的显示报警文件的方法。
在本公开实施例中,由于处理器通过长连接接收服务端的报警文件对应的数据包,处理器对报警文件对应的数据包进行解析得到报警文件,生成该报警文件的URL,这样根据该报警文件的URL显示该报警文件。如此处理器不需要采用轮询方式请求报警文件,这样服务器可以不保存报警文件,从而在推送报警文件后就可释放报警文件占用的存储资源,减小对服 务端的存储资源的占用,还避免了轮询导致大量消耗服务端的资源和带宽资源,提高推送报警文件的实时性。由于处理器生成该报警文件的URL,根据该URL可以自动显示该报警文件。
本领域技术人员在考虑说明书及实践这里公开的申请后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本申请的真正范围和精神由下面的权利要求指出。
应当理解的是,本申请并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本申请的范围仅由所附的权利要求来限制。

Claims (18)

  1. 一种显示报警文件的方法,其特征在于,所述方法包括:
    通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据包,其中所述服务端发送所述报警文件后释放所述报警文件占用的存储资源;
    对所述报警文件对应的数据包解析得到所述报警文件;
    生成所述报警文件的统一资源定位符URL;
    根据所述报警文件的URL显示所述报警文件。
  2. 如权利要求1所述的方法,其特征在于,所述报警文件对应M个数据包,M为大于或等于1的整数,所述对所述报警文件对应的数据包解析得到所述报警文件,包括:
    针对所述M个数据包中的每个数据包,从所述数据包的包头中读取校验字符串;
    在所述校验字符串为预设校验字符串的情况下,从所述包头中读取包头长度;
    根据所述包头长度,从所述包头中读取所述报警文件的文件长度、所述报警文件的文件标识和所述数据包的包序号;
    在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中;
    在所述存储结构中保存的属于所述报警文件的数据长度等于所述文件长度时,所述存储结构保存的属于所述报警文件的数据为所述报警文件。
  3. 如权利要求2所述的方法,其特征在于,所述数据包的包头还包括所述数据包的净荷长度,
    所述在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中,包括:
    根据所述文件标识,确定所述数据包是否是接收的第一个属于所述报警文件的数据包;
    如果是第一个,则创建所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,在所述存储结构中保存属于所述报警文件的数据长度,所述数据长度等于所述数据包的净荷长度;
    如果不是第一个,则确定所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,将所述存储结构中保存的属于所述报警文件的数据长度和所述数据包的净荷长度进行累加,得到累加值,将所述存储结构中保存的所述数据长度替换为所述累加值。
  4. 如权利要求1所述的方法,其特征在于,所述解析得到的报警文件保存在内存中,所述生成所述报警文件的统一资源定位符URL,包括:
    根据所述内存中保存的所述报警文件,通过用于生成统一资源定位符URL的应用程序接口API,生成所述报警文件的URL。
  5. 如权利要求1所述的方法,其特征在于,所述通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据包之前,还包括:
    通过所述长连接向服务端发送订阅请求消息,所述订阅请求消息包括内容类型;
    通过所述长连接接收所述报警文件对应的报警信息,所述报警文件的内容属于所述内容类型。
  6. 一种显示报警文件的装置,其特征在于,所述装置包括:
    接收模块,用于通过与服务端之间的长连接接收所述服务端发送的报警文件对应的数据 包,其中所述服务端发送所述报警文件后释放所述报警文件占用的存储资源;
    解析模块,用于对所述报警文件对应的数据包解析得到所述报警文件;
    生成模块,用于生成所述报警文件的统一资源定位符URL;
    显示模块,用于根据所述报警文件的URL显示所述报警文件。
  7. 如权利要求6所述的装置,其特征在于,所述报警文件对应M个数据包,M为大于或等于1的整数,所述解析模块,用于:
    针对所述M个数据包中的每个数据包,从所述数据包的包头中读取校验字符串;
    在所述校验字符串为预设校验字符串的情况下,从所述包头中读取包头长度;
    根据所述包头长度,从所述包头中读取所述报警文件的文件长度、所述报警文件的文件标识和所述数据包的包序号;
    在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中;
    在所述存储结构中保存的属于所述报警文件的数据长度等于所述文件长度时,将所述存储结构保存的属于所述报警文件的数据为所述报警文件。
  8. 如权利要求7所述的装置,其特征在于,所述数据包的包头还包括所述数据包的净荷长度,
    所述解析模块,用于:
    根据所述文件标识,确定所述数据包是否是接收的第一个属于所述报警文件的数据包;
    如果是第一个,则创建所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,在所述存储结构中保存属于所述报警文件的数据长度,所述数据长度等于所述数据包的净荷长度;
    如果不是第一个,则确定所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,将所述存储结构中保存的属于所述报警文件的数据长度和所述数据包的净荷长度进行累加,得到累加值,将所述存储结构中保存的所述数据长度替换为所述累加值。
  9. 如权利要求6所述的装置,其特征在于,所述解析得到的报警文件保存在内存中,所述生成模块,用于:
    根据内存中保存的所述报警文件,通过用于生成统一资源定位符URL的应用程序接口API,生成所述报警文件的URL。
  10. 如权利要求6所述的装置,其特征在于,所述装置还包括:发送模块,
    所述发送模块,用于通过所述长连接向服务端发送订阅请求消息,所述订阅请求消息包括内容类型;
    所述接收模块,还用于通过所述长连接接收所述报警文件对应的报警信息,所述报警文件的内容属于所述内容类型。
  11. 一种显示报警文件的系统,其特征在于,所述系统包括:客户端和服务端;
    所述服务端,用于通过与所述客户端之间的长连接向所述客户端发送报警文件对应的数据包,释放所述报警文件占用的存储资源;
    所述客户端,用于通过与所述服务端之间的长连接接收所述报警文件对应的数据包;对所述报警文件对应的数据包解析得到所述报警文件;生成所述报警文件的统一资源定位符URL;根据所述报警文件的URL显示所述报警文件。
  12. 如权利要求11所述的系统,其特征在于,所述报警文件对应M个数据包,M为大 于或等于1的整数,所述客户端,用于:
    针对所述M个数据包中的每个数据包,从所述数据包的包头中读取校验字符串;
    在所述校验字符串为预设校验字符串的情况下,从所述包头中读取包头长度;
    根据所述包头长度,从所述包头中读取所述报警文件的文件长度、所述报警文件的文件标识和所述数据包的包序号;
    在所述文件标识对应的存储结构中,将所述数据包的净荷部分保存在所述包序号对应的存储空间中;
    在所述存储结构中保存的属于所述报警文件的数据长度等于所述文件长度时,所述存储结构保存的属于所述报警文件的数据为所述报警文件。
  13. 如权利要求12所述的系统,其特征在于,所述数据包的包头还包括所述数据包的净荷长度,
    所述客户端,用于:
    根据所述文件标识,确定所述数据包是否是接收的第一个属于所述报警文件的数据包;
    如果是第一个,则创建所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,在所述存储结构中保存属于所述报警文件的数据长度,所述数据长度等于所述数据包的净荷长度;
    如果不是第一个,则确定所述文件标识对应的存储结构,在所述存储结构中将所述数据包的净荷部分保存到所述包序号对应的存储空间中,将所述存储结构中保存的属于所述报警文件的数据长度和所述数据包的净荷长度进行累加,得到累加值,将所述存储结构中保存的所述数据长度替换为所述累加值。
  14. 如权利要求11所述的系统,其特征在于,
    所述客户端,用于将解析得到的报警文件保存在内存中,根据所述内存中保存的所述报警文件,通过用于生成统一资源定位符URL的应用程序接口API,生成所述报警文件的URL。
  15. 如权利要求11所述的系统,其特征在于,
    所述客户端,还用于通过所述长连接向服务端发送订阅请求消息,所述订阅请求消息包括内容类型;通过所述长连接接收所述报警文件对应的报警信息,所述报警文件的内容属于所述内容类型;
    所述服务端,还用于通过所述长连接向所述客户端发送所述报警文件对应的报警信息。
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有至少一个指令,所述至少一个指令被处理器加载并运行,以实现如权利要求1至5中任一项所述的显示报警文件的方法。
  17. 一种计算机程序产品,所述计算机程序产品包括在计算机可读存储介质中存储的计算机程序,并且所述计算程序通过处理器进行加载来实现如权利要求1至5中任一项所述的显示报警文件的方法。
  18. 一种电子设备,包括至少一个处理器和至少一个存储器,所述至少一个存储器用于存储至少一个指令,所述至少一个指令被所述至少一个处理器加载并运行,以实现如权利要求1至5中任一项所述的显示报警文件的方法。
PCT/CN2020/125955 2019-11-06 2020-11-02 一种显示报警文件的方法、装置及系统 WO2021088773A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US17/772,811 US20220414178A1 (en) 2019-11-06 2020-11-02 Methods, apparatuses and systems for displaying alarm file
EP20885783.9A EP4044513A4 (en) 2019-11-06 2020-11-02 METHOD, APPARATUS AND SYSTEM FOR DISPLAYING AN ALARM FILE

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911077085.2 2019-11-06
CN201911077085.2A CN111427850A (zh) 2019-11-06 2019-11-06 一种显示报警文件的方法、装置及系统

Publications (1)

Publication Number Publication Date
WO2021088773A1 true WO2021088773A1 (zh) 2021-05-14

Family

ID=71546841

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/125955 WO2021088773A1 (zh) 2019-11-06 2020-11-02 一种显示报警文件的方法、装置及系统

Country Status (4)

Country Link
US (1) US20220414178A1 (zh)
EP (1) EP4044513A4 (zh)
CN (1) CN111427850A (zh)
WO (1) WO2021088773A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111427850A (zh) * 2019-11-06 2020-07-17 杭州海康威视数字技术股份有限公司 一种显示报警文件的方法、装置及系统
CN113242403A (zh) * 2021-03-31 2021-08-10 普天和平科技有限公司 一种服务器以及视频播放系统

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103543700A (zh) * 2012-06-27 2014-01-29 尤比奎蒂网络公司 控制传感器装置的方法和设备
GB2511067A (en) * 2013-02-21 2014-08-27 Vdt Direct Ltd Alarm notification system
CN106100914A (zh) * 2016-08-25 2016-11-09 上海斐讯数据通信技术有限公司 一种云ac告警信息的推送方法及系统
CN107231406A (zh) * 2017-04-21 2017-10-03 华北电力大学 一种向Web页面高效传输及推送报警数据方法
CN107342896A (zh) * 2017-07-04 2017-11-10 郑州云海信息技术有限公司 一种信息获取方法、装置及系统
CN109270850A (zh) * 2018-12-13 2019-01-25 桂林电子科技大学 一种基于物联网的智能家居管理系统及方法
CN111427850A (zh) * 2019-11-06 2020-07-17 杭州海康威视数字技术股份有限公司 一种显示报警文件的方法、装置及系统

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6349333B1 (en) * 1998-12-04 2002-02-19 Sun Microsystems, Inc. Platform independent alarm service for manipulating managed objects in a distributed network management system
KR100434270B1 (ko) * 2001-05-30 2004-06-04 엘지전자 주식회사 가전기기 네트워크 제어시스템
JP2004070859A (ja) * 2002-08-09 2004-03-04 Fujitsu Ltd 障害情報管理システム
US7512721B1 (en) * 2004-05-25 2009-03-31 Qlogic, Corporation Method and apparatus for efficient determination of status from DMA lists
JP2011118733A (ja) * 2009-12-04 2011-06-16 Yokogawa Electric Corp プログラマブルロジックコントローラ
US9501922B2 (en) * 2011-06-08 2016-11-22 Honeywell International Inc. System and method for automated posting of alarm information to news feed
CN104010039B (zh) * 2014-06-05 2017-05-10 北京航空航天大学 一种基于WebSocket的多雷达远程监控系统及方法
GB2534849A (en) * 2015-01-28 2016-08-10 Canon Kk Client-driven push of resources by a server device
US10033794B2 (en) * 2015-07-17 2018-07-24 Bio-Rad Laboratories, Inc. Network transfer of large files in unstable network environments
CN105610605B (zh) * 2015-12-18 2019-04-23 成都广达新网科技股份有限公司 一种消息反向推送、网管系统报警及状态更新的方法
CN107426029A (zh) * 2017-08-08 2017-12-01 郑州云海信息技术有限公司 一种信息获取方法、装置及系统
CN109067899A (zh) * 2018-08-24 2018-12-21 珠海格力电器股份有限公司 数据显示方法和装置、数据推送方法和装置
CN109508273A (zh) * 2018-09-21 2019-03-22 广东电网有限责任公司珠海供电局 一种基于Web的电动汽车充电站监控系统及数据获取方法

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103543700A (zh) * 2012-06-27 2014-01-29 尤比奎蒂网络公司 控制传感器装置的方法和设备
GB2511067A (en) * 2013-02-21 2014-08-27 Vdt Direct Ltd Alarm notification system
CN106100914A (zh) * 2016-08-25 2016-11-09 上海斐讯数据通信技术有限公司 一种云ac告警信息的推送方法及系统
CN107231406A (zh) * 2017-04-21 2017-10-03 华北电力大学 一种向Web页面高效传输及推送报警数据方法
CN107342896A (zh) * 2017-07-04 2017-11-10 郑州云海信息技术有限公司 一种信息获取方法、装置及系统
CN109270850A (zh) * 2018-12-13 2019-01-25 桂林电子科技大学 一种基于物联网的智能家居管理系统及方法
CN111427850A (zh) * 2019-11-06 2020-07-17 杭州海康威视数字技术股份有限公司 一种显示报警文件的方法、装置及系统

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4044513A4 *

Also Published As

Publication number Publication date
CN111427850A (zh) 2020-07-17
EP4044513A4 (en) 2022-11-16
EP4044513A1 (en) 2022-08-17
US20220414178A1 (en) 2022-12-29

Similar Documents

Publication Publication Date Title
CN111225042B (zh) 数据传输的方法、装置、计算机设备以及存储介质
CN108833963B (zh) 显示界面画面的方法、计算机设备、可读存储介质和系统
CN108966008B (zh) 直播视频回放方法及装置
US20220304094A1 (en) Bluetooth Reconnection Method and Related Apparatus
CN110837426B (zh) 消息处理方法、装置及系统、存储介质
CN111092809B (zh) 实时推送信息的方法、装置、计算机设备及存储介质
CN110569220B (zh) 游戏资源文件的展示方法、装置、终端及存储介质
WO2021088773A1 (zh) 一种显示报警文件的方法、装置及系统
JP6862564B2 (ja) 画像合成のための方法、装置および不揮発性コンピュータ可読媒体
CN108616835B (zh) 基于浏览器的网络资源获取方法、装置、系统及存储介质
CN110149491B (zh) 视频编码方法、视频解码方法、终端及存储介质
CN111106902B (zh) 数据报文传输方法、装置、设备及计算机可读存储介质
CN109995704B (zh) 广告拦截方法、装置、设备及计算机可读存储介质
CN110912830A (zh) 传输数据的方法和装置
CN110381155B (zh) 任务管理方法、装置、存储介质及终端
CN110086814B (zh) 一种数据获取的方法、装置及存储介质
CN107800720B (zh) 劫持上报方法、装置、存储介质及设备
CN108683699B (zh) 转发业务请求的方法和装置
CN114785766B (zh) 智能设备的控制方法、终端及服务器
CN110597840A (zh) 基于区块链的伴侣关系建立方法、装置、设备及存储介质
CN110475303A (zh) 一种数据传输方法及终端设备
CN114071224A (zh) 视频数据处理方法、装置、计算机设备及存储介质
CN113259370B (zh) 数据传输方法、装置、设备、系统及可读存储介质
CN108377291A (zh) 一种基于耳机接口的通信方法及移动终端
CN111142648B (zh) 一种数据处理方法和智能终端

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20885783

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020885783

Country of ref document: EP

Effective date: 20220425

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2020885783

Country of ref document: EP

Effective date: 20220425