CN106257887B - A method of the acquisition client hardware information based on WebSocket - Google Patents
A method of the acquisition client hardware information based on WebSocket Download PDFInfo
- Publication number
- CN106257887B CN106257887B CN201510342151.XA CN201510342151A CN106257887B CN 106257887 B CN106257887 B CN 106257887B CN 201510342151 A CN201510342151 A CN 201510342151A CN 106257887 B CN106257887 B CN 106257887B
- Authority
- CN
- China
- Prior art keywords
- hardware information
- websocket
- client
- function
- device hardware
- 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.)
- Expired - Fee Related
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/133—Protocols for remote procedure calls [RPC]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/34—Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Information Transfer Between Computers (AREA)
- Computer And Data Communications (AREA)
Abstract
The method for the acquisition client hardware information based on WebSocket that the present invention provides a kind of, which comprises step 1) is to the customized JavaScript interface function of common Web Socket object extension;Step 2) client creates WebSocket object, and establishes the connection with server, calls the customized JavaScript interface function of the extension of the step 1);Step 3) Web engine kernel obtains relevant device hardware information according to the interface function of WebSocket object reference, returns to client;The device hardware information of return is included in data message and is sent to server by step 4) client;Step 5) the server handles data message, and processing result is returned to client according to device hardware information;Step 6) client continues to send datagram to server according to the processing result of return, until communication finishes;After step 7) communicates, WebSocket connection is closed.
Description
Technical field
The invention belongs to network communication fields, and in particular to a kind of to obtain client hardware information based on WebSocket
Method.
Background technique
The final shaping of the ripe day by day and HTML5 specification of HTML5 technology, the technology emerging as one and has support
Cross-platform characteristic, HTML5 is increasingly by the welcome of developer.WebSocket is supported as one of HTML5 key technology
The advantage and developers of full-duplex communication and saving network bandwidth are opened in progress Web application communication even Overpassing Platform by Using
The communication mode preferentially selected when hair.
In standard WebSocket agreement, the attribute and method that WebSocket object has are than relatively limited, such as: attribute value
URL, method send and close etc..In exploitation Web application process, the letter for including sometimes is needed to the data message of transmission
Breath has more requirements, such as: the client ends relative comprising initiating WebSocket request is needed in message.But it lacks at present
The method that a kind of weary JavaScript interface by calling extension based on WebSocket obtains client hardware information.
Further, since send datagram needs obtain rather than modify client-side information, client-side information be by
It protects and not revisable, so obtaining relevant information to JavaScript has certain security requirement.
Summary of the invention
It is an object of the invention to overcome not having the category comprising obtaining client hardware information in current WebSocket object
Property defect, propose it is a kind of based on WebSocket obtain client hardware information method, this method by call extension
JavaScript interface realizes WebSocket object acquisition client hardware information, and this method is highly-safe, it is ensured that visitor
The hardware information at family cannot be modified.
To achieve the goals above, the acquisition client hardware information based on WebSocket that the present invention provides a kind of
Method, which comprises
Step 1) is to the customized JavaScript interface function of common Web Socket object extension;
Step 2) client creates WebSocket object, and establishes the connection with server, calls the expansion of the step 1)
Open up customized JavaScript interface function;
Step 3) Web engine kernel obtains relevant device hardware information according to the interface function of WebSocket object reference,
Return to client;
The device hardware information of return is included in data message and is sent to server by step 4) client;
Step 5) the server handles data message, and is returned to processing result according to device hardware information
Client;
Step 6) client continues to send datagram to server according to the processing result of return, until communication finishes;
After step 7) communicates, WebSocket connection is closed.
In above-mentioned technical proposal, the step 1) is specifically included:
Step 1-1) in browser kernel, to common Web Socket object add JavaScript interface attribute value or
Method;
Step 1-2) definition step 1-1) extension JavaScript interface attribute value or method browser kernel letter
Number mapping relations, are mapped to browser internal custom function;
Step 1-3) in the internal custom function of step 1-2), call the extension of WebSocket protocol realization to make by oneself
The function of the acquisition device hardware information of justice;
Step 1-4) inside WebSocket protocol realization, add customized acquisition device hardware information function;
The customized acquisition device hardware information function is the Custom Attributes value or method of WebSocket object,
Particular value is returned after calling as the requested client device hardware information of user;The device hardware information be MAC Address,
IP address or device id.
In above-mentioned technical proposal, the customized JavaScript interface function of the extension of the step 2) be step 1-4) from
The acquisition device hardware information function of definition.
Present invention has an advantage that
1, method of the invention by browser kernel extend the JavaScript interface based on WebSocket agreement,
Calling interface can get client hardware information, such as MAC Address, IP address, device id, and a part as data message
It is sent to server;This method is suitable for server requirement and obtains the case where client-side information is as mark, especially mostly objective
There is higher practical value in the case where the multi-platform combined operation in family end;
2, method of the invention is realized based on WebSocket, and WebSocket is the important component of HTML5 agreement,
Its cross-platform characteristic for having HTML5, there is biggish advantage in terms of Overpassing Platform by Using;
3, the method that method of the invention will acquire client-side information is packaged in WebSocket agreement, is passed through
The mode of WebSocket object reference obtains read-only attribute value or function return value, and user can only obtain and cannot modify visitor
Family client information, being capable of the biggish safety for guaranteeing client-side information.
Detailed description of the invention
Fig. 1 is the schematic diagram of the method for the invention that client hardware information is obtained based on WebSocket;
Fig. 2 is of the invention from client JavaScript to the function call mistake of browser kernel WebSocket agreement
Cheng Tu.
Specific embodiment
The present invention is described in detail in the following with reference to the drawings and specific embodiments.
As shown in Figure 1, a kind of method of the acquisition client hardware information based on WebSocket, the method are specifically wrapped
It includes:
Step 1) is to the customized JavaScript interface of common Web Socket object extension;
The common Web Socket object is all WebSocket objects of client creation;
As shown in Fig. 2, the step 1) specifically includes:
Step 1-1) in browser kernel, to common Web Socket object add JavaScript interface attribute value or
Method;
Step 1-2) definition step 1-1) extension JavaScript interface attribute value or method browser kernel letter
Number mapping relations, are mapped to browser internal custom function;
Step 1-3) in the internal custom function of step 1-2), call the extension of WebSocket protocol realization to make by oneself
The function of the acquisition device hardware information of justice;
Step 1-4) inside WebSocket protocol realization, add customized acquisition device hardware information function;
The customized acquisition device hardware information function is the Custom Attributes value or method of WebSocket object,
Particular value is returned after calling as the requested client device hardware information of user.
The device hardware information is MAC Address, IP address or device id.
Step 2) client creates WebSocket object, and establishes the connection with server, calls the expansion of the step 1)
Open up JavaScript interface function;
It is described to extend customized JavaScript interface function for the customized acquisition device hardware of the step 1-4)
Information function.
Step 3) Web engine kernel obtains relevant device hardware information according to the interface function of WebSocket object reference,
Return to client;
The device hardware information of return is included in data message and is sent to server by step 4) client;
Step 5) the server handles data message, and is returned to processing result according to device hardware information
Client;
Step 6) client continues to send datagram to server according to the processing result of return, until communication finishes;
After step 7) communicates, WebSocket connection is closed.
Below by taking the MAC Address for obtaining client as an example, the specific implementation process of step 1) are as follows:
Assuming that server is to reporting message format requirement are as follows:
{"operator":"sample","value":"sample","clientMac":"clientMacAddr"}
Then client JavaScript needs the client mac address that will acquire to be contained in clientMacAddr field,
Key component written in JavaScript mode is as follows:
Websocket=new WebSocket (" ws: //sample/ ");
Var clientMacAddr=websocket.DeviceMAC | | websocket.getDeviceMAC ();
Var msg=" { " operator ": " sample ", " value ": " sample ", "
clientMac\":\""+clientMacAddr+"\"}";
websocket.send(msg);
Wherein, DeviceMAC is the attribute of WebSocket object, and getDeviceMAC () is the side of WebSocket object
Method.
Browser kernel is to the customized JavaScript interface of WebSocket object extension, including following part:
In browser kernel, increase the JavaScript interface attribute value DeviceMAC or method of WebSocket object
getDeviceMAC();
JavaScript interface attribute value or method are defined in the Function Mapping relationship of browser kernel:
DeviceMAC->jsWebSocketDeviceMAC()
getDeviceMAC()->jsWebSocketPrototypeFunctionGetDeviceMAC()
Browser kernel function realize, call WebSocket agreement internal custom function DeviceMAC () or
getDeviceMAC();
Inside WebSocket protocol realization, customized function DeviceMAC () or getDeviceMAC () are added,
Realize the function of obtaining facility information.The foregoing is merely a specific embodiment of the invention, are not intended to limit of the invention
Protection scope, it will be understood by those of skill in the art that under the premise of not departing from inventive principle, to technical solution of the present invention
It is modified or replaced equivalently, without departure from the spirit and scope of technical solution of the present invention, should all cover of the invention
In protection scope.
Claims (2)
1. a kind of method of the acquisition client hardware information based on WebSocket, which comprises
Step 1) is to the customized JavaScript interface function of common Web Socket object extension;
Step 2) client creates WebSocket object, and establishes the connection with server, calls the extension of the step 1) certainly
Define JavaScript interface function;
Step 3) Web engine kernel obtains relevant device hardware information according to the interface function of WebSocket object reference, returns
To client;
The device hardware information of return is included in data message and is sent to server by step 4) client;
Step 5) the server handles data message, and processing result is returned to client according to device hardware information
End;
Step 6) client continues to send datagram to server according to the processing result of return, until communication finishes;
After step 7) communicates, WebSocket connection is closed;The step 1) specifically includes:
Step 1-1) in browser kernel, JavaScript interface attribute value or method are added to common Web Socket object;
Step 1-2) definition step 1-1) extension JavaScript interface attribute value or method reflected in the function of browser kernel
Relationship is penetrated, browser internal custom function is mapped to;
Step 1-3) in the internal custom function of step 1-2), call the extension of WebSocket protocol realization customized
Obtain the function of device hardware information;
Step 1-4) inside WebSocket protocol realization, add customized acquisition device hardware information function;
The customized device hardware information function that obtains calls for the Custom Attributes value or method of WebSocket object
Particular value is returned afterwards as the requested client device hardware information of user;The device hardware information is MAC Address, IP
Location or device id.
2. the method for the acquisition client hardware information according to claim 1 based on WebSocket, which is characterized in that
The customized JavaScript interface function of the extension of the step 2) be step 1-4) customized acquisition device hardware information
Function.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510342151.XA CN106257887B (en) | 2015-06-18 | 2015-06-18 | A method of the acquisition client hardware information based on WebSocket |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510342151.XA CN106257887B (en) | 2015-06-18 | 2015-06-18 | A method of the acquisition client hardware information based on WebSocket |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106257887A CN106257887A (en) | 2016-12-28 |
CN106257887B true CN106257887B (en) | 2019-06-18 |
Family
ID=57714044
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510342151.XA Expired - Fee Related CN106257887B (en) | 2015-06-18 | 2015-06-18 | A method of the acquisition client hardware information based on WebSocket |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106257887B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10572274B2 (en) | 2017-09-22 | 2020-02-25 | Microsoft Technology Licensing, Llc | Cross platform custom functions |
CN107888683A (en) * | 2017-11-10 | 2018-04-06 | 郑州云海信息技术有限公司 | A kind of client exchange method and device |
CN109144579B (en) * | 2018-07-17 | 2023-09-29 | 广州睿本信息科技有限公司 | Method for reading hardware by Web system and computer readable storage medium |
CN111045878B (en) * | 2019-12-03 | 2022-08-05 | 浪潮金融信息技术有限公司 | Cross-browser financial self-service terminal hardware calling method based on WebSocket |
CN114356678B (en) * | 2022-03-17 | 2022-06-14 | 北京奇立软件技术有限公司 | Method and system for acquiring hardware information of equipment |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104301443A (en) * | 2014-10-09 | 2015-01-21 | 百度在线网络技术(北京)有限公司 | Method and system for calling end capacity ports on web page |
-
2015
- 2015-06-18 CN CN201510342151.XA patent/CN106257887B/en not_active Expired - Fee Related
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104301443A (en) * | 2014-10-09 | 2015-01-21 | 百度在线网络技术(北京)有限公司 | Method and system for calling end capacity ports on web page |
Also Published As
Publication number | Publication date |
---|---|
CN106257887A (en) | 2016-12-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106257887B (en) | A method of the acquisition client hardware information based on WebSocket | |
US10027742B2 (en) | Techniques for sharing application states | |
CN104767775B (en) | Web application information push method and system | |
CN110855661B (en) | WebShell detection method, device, equipment and medium | |
EP3622415A1 (en) | Chat bot search results integration | |
US20170024763A1 (en) | Systems and Methods for MAC Address Tracking for a Mobile Device | |
CN103618606A (en) | App login method verified through short message | |
US9509786B2 (en) | Enabling mobile applications to acquire a MAC address for obtaining location information | |
WO2015021873A1 (en) | Method, platform server, and system of data pushing | |
CN106357609A (en) | User creation method and system, public network server and private cloud equipment | |
CN108207012B (en) | Flow control method, device, terminal and system | |
WO2016086755A1 (en) | Packet processing method and transparent proxy server | |
CN106534145A (en) | Application identification method and equipment | |
Mohamed et al. | A lightweight framework for web services implementations on mobile devices | |
CN109450733A (en) | A kind of network-termination device recognition methods and system based on machine learning | |
DE102014115895A1 (en) | Providing source insights to web applications through Session Traversal Utilities for Network Address Translation (STUN) messages and related methods, systems, and computer-readable media | |
CN107111645A (en) | Programmatically device and method of establishing resource finger URL | |
CN104410724A (en) | Method for realizing device type recognition in intelligent gateway based on HTTP protocol | |
CN103036895B (en) | A kind of status tracking method and system | |
CN104732144B (en) | A kind of remote code injection loophole detection method based on pseudo- agreement | |
CN105721205B (en) | A kind of method for pushing and router of APP download link | |
CN105745664B (en) | The guard method and protection system of the terminal local environment of malicious code in corresponding link information | |
CN104158884B (en) | Voice communication method based on mobile internet | |
US20170075880A1 (en) | Translation for web services | |
CN105897927A (en) | Method for analyzing Google longitude and latitude |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20190618 Termination date: 20200618 |