CN114363427A - Method for acquiring information of host equipment in real time based on browser - Google Patents
Method for acquiring information of host equipment in real time based on browser Download PDFInfo
- Publication number
- CN114363427A CN114363427A CN202111603519.5A CN202111603519A CN114363427A CN 114363427 A CN114363427 A CN 114363427A CN 202111603519 A CN202111603519 A CN 202111603519A CN 114363427 A CN114363427 A CN 114363427A
- Authority
- CN
- China
- Prior art keywords
- browser
- information
- client
- real time
- acquiring
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Images
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
The invention discloses a method for acquiring host equipment information in real time based on a browser, which comprises the following steps: based on a C/S architecture, a browser establishes WebSocket connection with a client; after the connection is successfully established, the browser sends a query message for acquiring host information to the client through a WebSocket protocol, and the client returns the equipment state information of the current host after receiving the message; when the host equipment information or the equipment state changes, the client actively sends the information to the browser. The invention solves the problem that the information of the existing host equipment is difficult to accurately obtain in real time.
Description
Technical Field
The invention relates to the technical field of network interaction, in particular to a method for acquiring information of host equipment in real time based on a browser.
Background
In some specific fields (such as operation and maintenance management), the server displays the local device information (such as information of serial number, capacity, MAC address of the hard disk, model number of the inserted usb flash disk, capacity, etc.). There are several methods for acquiring the information of the host device. And obtaining related interfaces of the Java third party package sigar. JNI calls a library interface mode packaged by C or C + +; the JNI is a part of the JDK and is used for providing a native code interface for Java, and allows Java programs running in the virtual machine to be mutually invoked with programs or class libraries written in other languages (C/C + +); by adopting JNI, the JAVA program can call the C/C + + class library to acquire the host information. However, the Java third party package and the JNI technology do not have the right to access the device under some systems, resulting in device information not being available.
Acquiring an HTTP POST mode of a C/S framework; the core of the method is to compile a C + + program and periodically send a POST form to a JAVA server by adopting an HTTP transmission protocol; and a C/S framework is adopted, and a C + + program sends a POST (POST on the screen) form to the JAVA server at regular time in a polling mode, so that the real-time property of data cannot be guaranteed.
Disclosure of Invention
Therefore, the invention provides a method for acquiring host equipment information in real time based on a browser, which aims to solve the problem that the existing host equipment information is difficult to acquire accurately in real time.
In order to achieve the above purpose, the invention provides the following technical scheme:
the invention discloses a method for acquiring host equipment information in real time based on a browser, which comprises the following steps:
based on a C/S architecture, a browser establishes WebSocket connection with a client;
after the connection is successfully established, the browser sends a query message for acquiring host information to the client through a WebSocket protocol, and the client returns the equipment state information of the current host after receiving the message;
when the host equipment information or the equipment state changes, the client actively sends the information to the browser. .
Furthermore, the browser is used as a connection initiating end, and the browser establishes a persistent connection with the client through a WebSocket protocol and performs bidirectional data transmission.
Further, the browser sends a request for inquiring the device information to the client, and the browser can be guaranteed to continuously send corresponding requests to the client based on the WebSocket protocol.
Further, the client acquires the local device information on the client after receiving the request for inquiring the device information sent by the browser.
Further, the local device information includes: hard disk serial number, capacity, MAC address, model and capacity information of the inserted U disk.
Furthermore, the client actively sends the local device information to the browser after acquiring the local device information, and the browser can display the device information.
Further, when the browser is closed, the WebSocket connection between the browser and the client is automatically disconnected.
Further, when the local device information in the client changes, the client automatically sends the change condition to the browser through the WebSocket protocol.
The invention has the following advantages:
compared with the traditional HTTP POST technical scheme, the method can better save server resources and bandwidth and can carry out communication in real time; reducing the bandwidth overhead: after the connection is established, the header of the data packet for protocol control is relatively small, generally only 2 bytes, when the server and the client exchange data compared with the HTTP request. Enhancing the instantaneity: the server can actively inquire data from the client at any time, and compared with the HTTP POST request that the client needs to wait for sending a data server-side update response, the delay is obviously less, and the data can be more efficiently transmitted in a short time. And maintaining the connection state: in some scenarios requiring identity authentication, each HTTP request may need to carry state information, the server does not record each request and response information, and the WebSocket maintains a session state after establishing a connection once, which makes the WebSocket a stateful protocol, and partial state information may be omitted during subsequent communication.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below. It should be apparent that the drawings in the following description are merely exemplary, and that other embodiments can be derived from the drawings provided by those of ordinary skill in the art without inventive effort.
The structures, ratios, sizes, and the like shown in the present specification are only used for matching with the contents disclosed in the specification, so as to be understood and read by those skilled in the art, and are not used to limit the conditions that the present invention can be implemented, so that the present invention has no technical significance, and any structural modifications, changes in the ratio relationship, or adjustments of the sizes, without affecting the effects and the achievable by the present invention, should still fall within the range that the technical contents disclosed in the present invention can cover.
Fig. 1 is an information interaction diagram of a method for acquiring information of a host device in real time based on a browser according to an embodiment of the present invention;
Detailed Description
The present invention is described in terms of particular embodiments, other advantages and features of the invention will become apparent to those skilled in the art from the following disclosure, and it is to be understood that the described embodiments are merely exemplary of the invention and that it is not intended to limit the invention to the particular embodiments disclosed. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Examples
The embodiment discloses a method for acquiring host equipment information in real time based on a browser, which comprises the following steps:
based on a C/S architecture, a browser establishes WebSocket connection with a client;
after the connection is successfully established, the browser sends a query message for acquiring host information to the client through a WebSocket protocol, and the client returns the equipment state information of the current host after receiving the message;
when the host equipment information or the equipment state changes, the client actively sends the information to the browser.
WebSocket is a protocol for full duplex communication over a single TCP connection. The WebSocket communication protocol was specified by the IETF as standard RFC6455 in 2011 and is supplemented by RFC 7936. WebSocketAPI is also standardized by W3C.
WebSocket enables data exchange between the client and the server to be simpler, and allows the server to actively push data to the client. In WebSocketAPI, the browser and the server only need to complete one handshake, and persistent connection can be directly established between the browser and the server, and bidirectional data transmission is carried out.
The WebSocket protocol is essentially a TCP-based protocol. To establish a WebSocket connection, the client browser first initiates an HTTP request to the server, which, unlike the normal HTTP request, contains some additional header information.
The browser is used as a connection initiating end, in this embodiment, the browser may also be a JAVA server, persistent connection is established between the browser and the client through a WebSocket protocol, and bidirectional data transmission is performed, the browser sends a request for querying device information to the client, and based on the WebSocket protocol, the browser can be ensured to continuously send a corresponding request to the client.
After receiving a request for querying device information sent by a browser, a client acquires local device information on the client, where the client in this embodiment adopts a C + + client, and the local device information includes: hard disk serial number, capacity, MAC address, model and capacity information of the inserted U disk.
The client actively sends the local device information to the browser after acquiring the local device information, and the browser can display the device information. And when the browser is closed, the WebSocket connection between the browser and the client is automatically disconnected. When the local device information in the client changes, the client automatically sends the change condition to the browser through the WebSocket protocol.
Compared with the traditional HTTP POST technical scheme, the method for acquiring the information of the host equipment in real time based on the browser can better save server resources and bandwidth and can perform communication in real time; reducing the bandwidth overhead: after the connection is established, the header of the data packet for protocol control is relatively small, generally only 2 bytes, when the server and the client exchange data compared with the HTTP request. Enhancing the instantaneity: the server can actively inquire data from the client at any time, and compared with the HTTP POST request that the client needs to wait for sending a data server-side update response, the delay is obviously less, and the data can be more efficiently transmitted in a short time. And maintaining the connection state: in some scenarios requiring identity authentication, each HTTP request may need to carry state information, the server does not record each request and response information, and the WebSocket maintains a session state after establishing a connection once, which makes the WebSocket a stateful protocol, and partial state information may be omitted during subsequent communication.
Although the invention has been described in detail above with reference to a general description and specific examples, it will be apparent to one skilled in the art that modifications or improvements may be made thereto based on the invention. Accordingly, such modifications and improvements are intended to be within the scope of the invention as claimed.
Claims (8)
1. A method for acquiring information of host equipment in real time based on a browser is characterized in that the method comprises the following steps:
based on a C/S architecture, a browser establishes WebSocket connection with a client;
after the connection is successfully established, the browser sends a query message for acquiring host information to the client through a WebSocket protocol, and the client returns the equipment state information of the current host after receiving the message;
when the host equipment information or the equipment state changes, the client actively sends the information to the browser.
2. The method for acquiring information of a host device in real time based on a browser as claimed in claim 1, wherein the browser is used as a connection initiator, and the browser establishes a persistent connection with a client through a WebSocket protocol, and performs bidirectional data transmission.
3. The method for acquiring the information of the host device in real time based on the browser as claimed in claim 1, wherein the browser sends a request for inquiring the device information to the client, and the browser can be guaranteed to continuously send a corresponding request to the client based on a WebSocket protocol.
4. The method as claimed in claim 1, wherein the client obtains the local device information from the client after receiving a request for querying the device information from the browser.
5. The method of claim 4, wherein the obtaining of the information of the host device in real time based on the browser comprises: hard disk serial number, capacity, MAC address, model and capacity information of the inserted U disk.
6. The method for acquiring information of a host device in real time based on a browser as claimed in claim 1, wherein the client actively sends the information of the host device to the browser after acquiring the information of the host device, and the browser can display the information of the host device.
7. The method for acquiring information of a host device in real time based on a browser as claimed in claim 1, wherein when the browser is closed, the WebSocket connection between the browser and the client is automatically disconnected.
8. The method for acquiring the information of the host device in real time based on the browser as claimed in claim 1, wherein when the information of the local device in the client changes, the client automatically sends the change condition to the browser through a WebSocket protocol.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111603519.5A CN114363427A (en) | 2021-12-24 | 2021-12-24 | Method for acquiring information of host equipment in real time based on browser |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111603519.5A CN114363427A (en) | 2021-12-24 | 2021-12-24 | Method for acquiring information of host equipment in real time based on browser |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114363427A true CN114363427A (en) | 2022-04-15 |
Family
ID=81101868
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111603519.5A Pending CN114363427A (en) | 2021-12-24 | 2021-12-24 | Method for acquiring information of host equipment in real time based on browser |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114363427A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115277656A (en) * | 2022-07-26 | 2022-11-01 | 广州鑫景信息科技服务有限公司 | Electronic work ticket duplicating system based on card printer and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102546794A (en) * | 2011-12-30 | 2012-07-04 | 华为技术有限公司 | Method for directly communicating browser client with back-end server as well as gateway and communication system |
CN105450479A (en) * | 2016-01-04 | 2016-03-30 | 山东超越数控电子有限公司 | Method and apparatus for monitoring module |
CN108667861A (en) * | 2017-03-28 | 2018-10-16 | 比亚迪股份有限公司 | By browser to the method, system and server of device real-time monitoring |
CN112565214A (en) * | 2020-11-26 | 2021-03-26 | 中国船舶工业系统工程研究院 | Data transmission method, system and medium based on WebSocket |
-
2021
- 2021-12-24 CN CN202111603519.5A patent/CN114363427A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102546794A (en) * | 2011-12-30 | 2012-07-04 | 华为技术有限公司 | Method for directly communicating browser client with back-end server as well as gateway and communication system |
CN105450479A (en) * | 2016-01-04 | 2016-03-30 | 山东超越数控电子有限公司 | Method and apparatus for monitoring module |
CN108667861A (en) * | 2017-03-28 | 2018-10-16 | 比亚迪股份有限公司 | By browser to the method, system and server of device real-time monitoring |
CN112565214A (en) * | 2020-11-26 | 2021-03-26 | 中国船舶工业系统工程研究院 | Data transmission method, system and medium based on WebSocket |
Non-Patent Citations (2)
Title |
---|
LIJING ZHANG ET AL.: "Research and development of real-time monitoring system based on websocket technology", IEEE * |
李斌斌: "基于WebSocket协议的车联网监控系统", 《中国优秀硕士学位论文全文数据库》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115277656A (en) * | 2022-07-26 | 2022-11-01 | 广州鑫景信息科技服务有限公司 | Electronic work ticket duplicating system based on card printer and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5931913A (en) | Methods, system and computer program products for establishing a session between a host and a terminal using a reduced protocol | |
US6115744A (en) | Client object API and gateway to enable OLTP via the internet | |
US7664067B2 (en) | Preserving socket connections over a wireless network | |
EP2843908B1 (en) | Full-duplex bi-directional communication over a remote procedure call based communications protocol, and applications thereof | |
CN110300050A (en) | Information push method, device, computer equipment and storage medium | |
US10298627B2 (en) | Concentration of independent tunneled encapsulated media | |
US8291486B2 (en) | Gateway device having socket library for monitoring, communication method of gateway device having socket library for monitoring, and communication program of gateway device having socket library for monitoring | |
CN112631788B (en) | Data transmission method and data transmission server | |
CN111294399B (en) | Data transmission method and device | |
US20040186918A1 (en) | Method and apparatus for dispatching incoming data in a multi-application terminal | |
CN107528891B (en) | Websocket-based automatic clustering method and system | |
US20170048192A1 (en) | Multihoming for tunneled encapsulated media | |
CN110769009B (en) | User identity authentication method and system | |
US10574518B2 (en) | Method and apparatus of performing remote management of a managed machine | |
WO2024037296A1 (en) | Protocol family-based quic data transmission method and device | |
WO2007075203A1 (en) | A sip multi-user media client comprising a user agent to be shared by a plurality of user applications | |
CN107332854B (en) | Message serialization negotiation method and service providing equipment | |
CN115664989A (en) | Monitoring system and method of cloud desktop | |
US6401123B1 (en) | Systems, methods and computer program products for employing presumptive negotiation in a data communications protocol | |
CN114363427A (en) | Method for acquiring information of host equipment in real time based on browser | |
CN110225135B (en) | Server connection method and device, electronic equipment and storage medium | |
CN111265852A (en) | Low-delay information transmission method and device based on UDP (user Datagram protocol) | |
WO2023284231A1 (en) | Message processing method and message processing system | |
CN113411228B (en) | Network condition determining method and server | |
US10334086B2 (en) | Header redundancy removal for tunneled media traffic |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |