This application claims priority to and the benefit of Chinese Patent Application Serial No. 201410857756.8, filed with the State Intellectual Property Office of P.R. China on Dec. 31, 2014, the content of which is incorporated herein by reference in its entirety.
The present invention relates to the field of Internet communication technologies, and in particular, to a method and an apparatus for implementing communication from a web page to a client.
As the network era develops, user applications based on the Internet, such as network games, network shopping and network videos are increasingly broad. Generally, network games, network videos and the like all have their corresponding portal web sites on the Internet, and a user needs to install a corresponding client locally to access a portal web site to implement various interaction operations.
In the prior art, in a case that a client has been installed locally and is not installed for the first time, when it intends to implement some services provided by a portal web site, the local client is started to access a home page of the corresponding web site, and the user voluntarily finds an entry of a designated page. In a case that no client is installed, a corresponding service provided on the portal web site may not be implemented. For example, when a network game client is activated from a portal page embedded in Alipay to receive a red envelope, an ideal implementation manner is jumping directly from Alipay to a corresponding page (not the home page) provided by the network game client for receiving the red envelope. However, the prior art obviously cannot implement this operation. Therefore, the complexity of operation of the user is increased.
A major technical problem solved by the present invention is to provide a method and an apparatus for implementing communication from a web page to a client, so that an interaction bridge is established between a portal web site and a client, thereby implementing direct calling of the client from a web page of the portal web site, and guiding a user to complete a required service to a designated page, thereby being convenient for the user to operate.
The present invention has the following beneficial effects: the present invention provides a method and an apparatus for implementing communication from a web page to a client, when a communication connection is established between a web page accessed by a browser and a predefined port, link information carrying parameters specified by a preset communication protocol is sent to the port, so that the client can access a client page corresponding to the link information; therefore, a connection between the web page and the client is established, thereby implementing direct communication from the web page to the client for interaction and service processing, and facilitating the operation of the user.
One aspect of the present invention provides a method for implementing communication from a web page to a client, comprising: establishing, by a browser, a communication connection with a port when accessing a web page, wherein the port is predefined to communicate with the web page; and transmitting to the port link information carrying parameters defined in implementation of a communication protocol, allowing user to access a client page on the client corresponding to the link information, wherein the parameters comprise fields in a service request and client page information.
These and other aspects of the invention are described further herein below.
The present invention is described in detail in the following through the accompanying drawings and implementation manners.
Referring to
Step S10: A browser establishes a communication connection with a port when accessing a web page. The port is predefined to communicate with the web page.
Specifically, the browser sends a connection request to attempt to communicate with the predefined port, and when a communication connection can be established, it indicates that the client has been installed. When the client has been installed, a background process of the client monitors the port through socket, and when the connection request sent by the web page is received, a communication connection is established between the port and the web page.
Step S12: Link information carrying parameters defined in implementation of communication protocol is sent to the port, allowing a user to access a client page corresponding to the link information on the client terminal, which may also be referred to as an end client or a client end. The parameters include fields in a service request and page information on the client.
The web page accessed by the browser may be a portal web site, and multiple web page elements may be displayed on the web page, where some web page elements are set to associate with a service and a client that executes the service. When a selection to a web page element of at least one set service is received in a process of accessing the web page, a corresponding service request is generated, and at the same time, a client executing the service request is determined. The link information is a web page that may be accessed by the client when executing the service request.
In this embodiment, link information carrying parameters specified by a preset communication protocol is sent when communication between a web page accessed by a browser and an installed client is established, allowing the client to access a web page corresponding to the link information on the client terminal, thereby implementing direct communication between the web page and the client for interaction and service processing. Therefore, a connection between the web page and the client is established, thereby implementing direct communication from the web page to the client for interaction and service processing, and facilitating the operation of the user.
Referring to
Step S20: It is determined whether a communication connection can be established with a port. If yes, step S21 is performed; otherwise, step S23 is performed.
Step S21: A browser establishes a communication connection with the port when accessing a web page. The port is predefined to communicate with a web page.
Step S22: Link information carrying parameters specified by a preset communication protocol is sent to the port, allowing the client to access a web page corresponding to the link information on a client terminal. The parameters include fields in a service request and client page information. Then, the process ends.
Step S23: The client is downloaded, or a hyperlink address to download the client is provided to obtain an installation package of the client for installing the client, where a file name of the installation package includes the link information, allowing user to access the web page corresponding to the link information on the client terminal when being started for the first time. Then, the process ends.
Specifically, when the browser attempts to communicate with the predefined port, if a communication connection is established successfully, it indicates that the client has been installed; and if a communication connection is not established, it indicates that the client is not installed.
When the client is not installed, the browser may provide the hyperlink download address of the client to prompt the user to download. When the client is installed and started for the first time, file name information of the installation package is acquired by scanning download folder in sdcard, so as to acquire corresponding link information, and therefore, the client may directly access a web page corresponding to the link information after being started on the client terminal.
Referring to step S22 of
Step S30: The parameters are defined to set a uniform resource locator (URL) in implementation of the communication protocol, so as to obtain the link information.
The communication protocol defines parameter specifications. The URL carries the parameters defined by the communication protocol. The parameters include fields of the service request and client page information.
Further, the communication protocol includes a URL protocol and a file name protocol, and the communication protocol defines protocol versions, service sets, operation methods, parameter sets and check bits of the URL protocol and the file name protocol. Specifically, specifications of service request defined by the communication protocol are shown as follows:
The protocol fields g, b, m, p and the like are case-insensitive, and MD5 is case-insensitive.
g—gamemanager represents a version;
b—business represents a service name;
m—method represents an operation method;
p—parameters represents parameters;
hash represents a check character string; and
the serial numbers in the communication protocol take a number in range of 10-99, so that almost ten thousand means of operations obtained by multiplying the service set by the operation method may be acquired, and therefore, it is applicable for the web page accessed by the browser to call the client to execute various services. For example, b12 represents a game type service, b14 represents a gift bag type service, m12 represents a concern operation, and b12m12 and b14m12 respectively represent concerning a game and concerning a game gift bag.
A parameter stitching rule in the parameter set may use sequential stitching using underline, or use other stitching manners, which is determined by a specific interface, and is not specified uniformly, to avoid inadaptability when parsing and stitching special parameters. When there is no parameter, the parameter set is p.
The manner of generating the check bits is: performing MD5 on the whole string, and the first 4 bits are used. When the client performs check, the last four bits of the protocol string are used.
The communication protocol first simply uses the check bits to check the whole message string, and if the check is not passed, the subsequent operation of calling the client will not be executed, so as to avoid program abnormality due to tampering of some fields. After the file name is scanned into the program and the check is not passed, the home page is directly opened.
A URL example: http://127.0.0.1:9998?hfp=g1b12m11p527432ba98;
A file name example: ninegame_g1b12m11p527432ba98.apk;
Note: b12m11 represents viewing the game, p527432 represents that a game Id is 527432, and ba98 is a four digit md5 check code.
The application of the check bits will be described in detail in the following.
Step S31: The URL is sent to a port, enabling the client to parse parameters carried by the URL according to the communication protocol and access the corresponding client page.
Referring to
Step S31a: The URL is sent to a port, enabling the client to check the parameters carried by the URL according to the check bits of the communication protocol and parse the parameters carried by the URL according to the communication protocol when the check is passed and access the client page.
For other steps in
A method for implementing communication from a web page to a client is described through examples in the following.
In a process of accessing a web page, a browser receives a service request generated by operating the web page, where the accessed web page is an access page of a portal web site, and the service request is that a user of the client can receive a red envelope in a red envelope receiving activity provided by the portal web site. In this embodiment, the accessed web page attempts to communicate with a port 127.0.0.1:9988.
When a communication connection is established with the port, a URL is generated through implementation of the communication protocol as described above, for example, http://127.0.0.1:9998?hfp=g1b12m11p527432ba98, and the URL is sent to the port through the communication protocol, so that the client receives the URL.
The client performs check when receiving the URL, and if the check is passed, the URL parameters are parsed according to the communication protocol to acquire a web page corresponding to the activity and user information, to directly jump to a corresponding client page, for example, a red envelope receiving page, so as to fill the user information and guide the user to receive the red envelope, thereby executing the corresponding service request.
When a communication connection is not established with the port, it indicates that the client is not installed, and the client is downloaded or a hyperlink download address of the client is provided to prompt the user to download, where page information and user information corresponding to the red envelope activity are written in a file name of the installation package of the client according to the communication protocol. When the user installs the client and starts the client for the first time, a user download directory is scanned on the client terminal to acquire a file name of the installation package, and the file name is then parsed according to the communication protocol to obtain the page information corresponding to the red envelope activity and the user information. User is directed to the red envelope activity page according to the page information corresponding to the red envelope activity, fills the user information automatically, and guides the user to receive the red envelope.
In this way, direct calling from the web page of the red envelope activity page on the client is implemented, thereby implementing direct communication between the web page and the client. When the user does not install the client, the user may be prompted to download the installation package by providing a hyperlink of download, and after the user completes installation, the user is guided to the red envelope activity page.
Referring to
Step S50: A client establishes, via a port, a communication connection with a web page accessed by a browser, so as to receive link information sent by the browser and carrying parameters defined in implementation of communication protocol. The port is predefined to communicate with a web page.
Further, the link information is a URL. The URL is set when the parameters are defined in implementation of the communication protocol by the browser. The URL carries the parameters defined by the communication protocol. The parameters include fields of the service request and web page information on the client terminal. The communication protocol includes a URL protocol and a file name protocol, and the communication protocol defines protocol versions, service sets, operation methods, parameter sets and check bits of the URL protocol and the file name protocol. The specific details may be obtained with reference to the related content in the foregoing, and are not repeated herein.
Specifically, when the client has been installed, the port is monitored on the client terminal through a socket, and when a connection request sent by the web page is received, a communication connection is established between the port and the web page, so as to receive link information sent by the browser.
Step S51: A client page corresponding to the link information is accessed.
Specifically, when the link information is a URL, parameters carried by the URL are parsed on the client terminal according to the communication protocol, allowing user to access the web page on the client terminal.
Further, the parameters carried by the URL are checked on the client terminal according to the communication protocol. The parameters are then parsed when the check is passed, allowing user to access the web page on client.
Referring to
The communication module 61 is configured to establish a communication connection with a port when accessing a web page. The port is predefined to communicate with the web page.
Specifically, the communication module 61 sends a connection request to attempt to communicate with the predefined port, and when a communication connection can be established, it indicates that the client has been installed. When the client has been installed, a background process of the client monitors the port through socket, and when the connection request sent by the web page is received, a communication connection is established between the port and the web page.
The transmission module 62 is configured to send to the port link information carrying parameters defined in implementation of a communication protocol, enabling the client to access a client page on the client terminal corresponding to the link information.
The accessed web page may be a portal web site, and multiple web page elements are displayed on the web page, where some web page elements are set to a corresponding service and a client executing the service. When a web page element of at least one set service is received in a process of accessing the web page, a corresponding service request is generated, and at the same time, a client executing the service request is determined. The link information is a web page that may be accessed by the client when executing the service request.
Referring to
Specifically, when the communication module 61 attempts to communicate with the predefined port, if the determining module 73 determines that a communication connection can be established, it indicates that the client has been installed. If the communication connection cannot be established, it indicates that the client is not installed.
When the client is not installed, the downloading module 74 provides the hyperlink download address of the client to prompt the user to download. When the client is installed and started for the first time, file name information of the installation package is acquired by scanning a download folder in an sdcard, so as to acquire corresponding link information, and therefore, the user can directly access a client page on the client terminal corresponding to the link information after being started.
Further, the apparatus 70 further includes a link information generating module 75, configured to define the parameters in implementation of the communication protocol and set a uniform resource locator (URL), so as to obtain the link information.
The communication protocol defines parameters. The URL carries the parameters defined in implementation of the communication protocol. The parameters include fields of the service request and client page information.
Further, the communication protocol includes a URL protocol and a file name protocol, and the communication protocol defines protocol versions, service sets, operation methods, parameter sets and check bits of the URL protocol and the file name protocol. Specifically, the service request defined by the communication protocol are as follows:
The protocol fields g, b, m, p, and the like are case-insensitive, and MD5 is case-insensitive.
g—gamernanager represents a version;
b—business represents a service name;
m—method represents an operation method;
p—parameters represents parameters;
hash represents a check character string; and
the serial numbers in the communication protocol take a number in the range of 10-99.
The apparatus 70 further includes a transmission module 72. The transmission module 72 transmits the URL generated by the link information generating module 75 to the port, so that parameters carried by the URL are parsed on the client terminal according to the communication protocol, enabling user to access the client page on the client terminal.
For other modules in
Referring to
The message receiving module 81 is configured to receive link information sent by the browser and carrying parameters defined in implementation of communication protocol when establishing, via a port, a communication connection with a web page accessed by a browser. The port predefined to communicate with the web page.
Further, the link information is a URL. The URL is set when the parameters are defined in implementation of the communication protocol by the browser. The URL carries the parameters defined by the communication protocol. The parameters include fields of the service request and web page information on client terminal.
The executing module 82 is configured to access a client page corresponding to the link information.
When the link information corresponding to the service request is the URL, the executing module 82 parses parameters carried by the URL according to the communication protocol, so as to access the client page and execute the corresponding service request.
The communication protocol is used to define specifications of the service request. The URL carries the parameters defined by the communication protocol. The parameters include fields of the service request and client page information.
Further, the communication protocol includes a URL protocol and a file name protocol. The communication protocol defines protocol versions, service sets, operation methods, parameter sets and check bits of the URL protocol and the file name protocol.
Referring to
Further, the apparatus 90 further includes an executing module 92 and a checking module 94. When the link information is the URL, the checking module 94 checks, according to the communication protocol, the parameters carried by the URL received by the message receiving module 91. The executing module 92 parses the parameters carried by the URL according to the communication protocol when the check is passed, so as to access the client page.
For other modules in
Embodiments of the present invention provide a method and an apparatus for implementing communication from a web page to a client, a communication connection is established between a web page accessed by a browser and a port predefined by the client terminal, and link information carrying parameters specified by a preset communication protocol is sent to the port, so that the client can access a client page corresponding to the link information. Therefore, a connection between the web page and the client is established, thereby implementing direct communication from the web page to the client for interaction and service processing, and facilitating the operation of the user.
The above descriptions are implementation manners of the present invention, and are not intended to limit the scope of the present invention. Any equivalent structure or equivalent flow variation made by using the description and accompanying drawings of the present invention and applied directly or indirectly in other related technical fields shall all fall within the protection scope of the present invention.
Number | Date | Country | Kind |
---|---|---|---|
2014 1 0857756 | Dec 2014 | CN | national |
Number | Name | Date | Kind |
---|---|---|---|
6006266 | Murphy, Jr. | Dec 1999 | A |
7519653 | Coutts | Apr 2009 | B1 |
7739590 | Stocker | Jun 2010 | B2 |
8209430 | Barreto | Jun 2012 | B2 |
8429736 | Green | Apr 2013 | B2 |
8479263 | Liu | Jul 2013 | B1 |
8972558 | Horton | Mar 2015 | B1 |
9324098 | Agrawal | Apr 2016 | B1 |
9582817 | Keithley | Feb 2017 | B2 |
20050021858 | Ruston | Jan 2005 | A1 |
20050198332 | Laertz | Sep 2005 | A1 |
20060092861 | Corday | May 2006 | A1 |
20060195687 | Klein | Aug 2006 | A1 |
20070174191 | Keaton | Jul 2007 | A1 |
20070198524 | Branda | Aug 2007 | A1 |
20110035319 | Brand | Feb 2011 | A1 |
20110166922 | Fuerstenberg | Jul 2011 | A1 |
20110307490 | Chow | Dec 2011 | A1 |
20120116925 | Jamkhedkar | May 2012 | A1 |
20120131228 | Kim | May 2012 | A1 |
20120210011 | Liu | Aug 2012 | A1 |
20130132491 | Watanabe | May 2013 | A1 |
20130275492 | Kaufman | Oct 2013 | A1 |
20130290475 | Flagg | Oct 2013 | A1 |
20140025726 | Chen | Jan 2014 | A1 |
20140122733 | Kadota | May 2014 | A1 |
20150188979 | Almeras | Jul 2015 | A1 |
20150271294 | Ma | Sep 2015 | A1 |
20150295885 | Congdon | Oct 2015 | A1 |
20150339661 | Li | Nov 2015 | A1 |
20150358334 | Lantz | Dec 2015 | A1 |
20160100025 | Ebner | Apr 2016 | A1 |
20160225059 | Chow | Aug 2016 | A1 |
Number | Date | Country | |
---|---|---|---|
20160191633 A1 | Jun 2016 | US |