Chat room game loading method and device based on Android

By integrating Web Server in Android client and developing web format games using the Cocos engine, the problem of old versions in the existing technology does not support new games and high maintenance costs are solved, and the game compatibility on various Android devices is achieved. Flexible update and maintenance.

CN119473327APending Publication Date: 2025-02-18BEIJING LANGMA SHULIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411544366.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

When developing chat room interactive mini games in the existing technology, the old version does not support new games, the maintenance cost is high, and the game cannot be adjusted and optimized online when there are problems, so it can only be updated by releasing the new version.

Method used

Integrate Web Server within the client, develop games with the Cocos engine and export them to web format, load web games with Web Server drivers, make them run on a variety of Android devices, including older versions, and allow instant tweaking and fixing Game content, no need to release new versions of the app.

Benefits of technology

It realizes the compatibility of the game on various Android devices, and is not limited to the differences in Android versions, reduces maintenance costs, improves the flexibility of game updates and maintenance, and can quickly respond to user feedback and optimize.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473327A_ABST
    Figure CN119473327A_ABST
Patent Text Reader

Abstract

The invention provides a chat room game loading method and device based on Android, a Web Server is integrated in a client, the method is applied to the client, and the method comprises the following steps: sending a Web game downloading request to the server; receiving a Web game package (developed based on a Cocos engine and exported in a Web format) issued by the server; the downloaded Web game package is checked and decompressed; and loading and displaying the Web game through a Web Server drive. A Cocos engine is used for developing a game and exporting the game into a Web format, a Web Server driver integrated in a client side is used for loading a Web game, the game can be operated on various Android devices (including devices of old versions), instant adjustment and repair are allowed when game content goes wrong, application programs of new versions do not need to be issued, game updating and maintenance are more flexible, and the method is easy to implement. And the maintenance cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Android development technology, and in particular to a method and device for loading games in a chat room based on Android. Background Art

[0002] In Android applications, the function of interactive games in chat rooms is becoming more and more popular, especially in social applications, entertainment platforms and online communities. Room interactive games can not only improve user participation and interactivity, but also provide users with a rich entertainment experience.

[0003] The current existing technology is to use native Android technology to develop interactive mini-game functions, but this solution has the following defects: the old version does not support new games, the maintenance cost is high, and when problems occur in the game, it cannot be adjusted and optimized online and can only be updated with a new version. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a method and device for loading games in a chat room based on Android, so that by integrating a Web Server in a client, using the Cocos engine to develop games and exporting them to a Web format, and using a Web Server driver to load Web games, the method can be run on various Android devices (including older versions of devices), and allows for immediate adjustments and repairs when problems occur in the game content, without the need to release a new version of the application, making game updates and maintenance more flexible and reducing maintenance costs.

[0005] In order to achieve the above purpose, the embodiments of the present application are implemented in the following manner:

[0006] In a first aspect, an embodiment of the present application provides a chat room game loading method based on Android, wherein a Web Server is integrated in a client, and the method is applied to the client, including: sending a Web game download request to a server; receiving a Web game package sent by the server, wherein the Web game package is developed based on a Cocos engine and exported to a Web format; verifying and decompressing the downloaded Web game package; and loading and displaying the Web game through a Web Server driver.

[0007] In combination with the first aspect, in a first possible implementation of the first aspect, sending a Web game download request to a server includes: generating a Web game list display request based on a user operation and sending it to the server; displaying the Web game list returned by the server; and generating a Web game download request based on a user selection and sending it to the server.

[0008] In combination with the first aspect, in a second possible implementation of the first aspect, the WebServer integrated in the client includes a configured listening port and root directory, and loads and displays the Web game through the Web Server driver, including: deploying the Web game to the root directory of the Web Server; the Web Server listens to the HTTP request from the WebView in the client through the listening port; the Web Server parses the received HTTP request and searches for the corresponding Web game resources in the root directory to generate an HTTP response and return it to the WebView; the WebView receives the HTTP response returned by the Web Server, parses the Web game resources in the HTTP response, and then updates the interface and status of the Web game according to the Web game resources.

[0009] In combination with the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the interaction between the Web Server and the client is implemented by interactively transmitting data through JavascriptInterface and HTML.

[0010] In combination with the third possible implementation method of the first aspect, in a fourth possible implementation method of the first aspect, data is transmitted interactively through JavascriptInterface and HTML, specifically including: defining a class of a JavascriptInterface interface, and annotating it to be callable by JavaScript; binding the defined JavascriptInterface object to a WebView instance; calling Android's native method by specifying a name in HTML / JavaScript, calling a JavaScript function by the evaluateJavascript method of WebView, to achieve two-way communication between JavascriptInterface and HTML, wherein the specified name is the name specified in the addJavascriptInterface method.

[0011] In a second aspect, an embodiment of the present application provides a chat room game loading device based on Android, wherein a Web Server is integrated in a client, and the device is applied to the client, comprising: a game request unit, for sending a Web game download request to a server; a game download unit, for receiving a Web game package sent by the server, wherein the Web game package is developed based on the Cocos engine and exported to a Web format; a verification and decompression unit, for verifying and decompressing the downloaded Web game package; and a game driver unit, for loading and displaying the Web game through a Web Server driver.

[0012] In combination with the second aspect, in a first possible implementation manner of the second aspect, the game request unit is specifically used to: based on user operations, generate a Web game list display request and send it to a server; display the Web game list returned by the server; based on user selection, generate a Web game download request and send it to the server.

[0013] In combination with the second aspect, in a second possible implementation of the second aspect, the WebServer integrated in the client includes a configured listening port and root directory, and a game driver unit, which is specifically used to: deploy the Web game to the root directory of the WebServer; the Web Server listens to the HTTP request from the WebView in the client through the listening port; the WebServer parses the received HTTP request and searches for the corresponding Web game resources from the root directory to generate an HTTP response and return it to the WebView; the WebView receives the HTTP response returned by the Web Server, parses the Web game resources in the HTTP response, and then updates the interface and status of the Web game according to the Web game resources.

[0014] In a third aspect, an embodiment of the present application provides a storage medium, which is arranged in an electronic device and includes a stored program, wherein when the program is running, the electronic device where the storage medium is located is controlled to execute the chat room game loading method based on Android as described in the first aspect or any one of the possible implementation methods of the first aspect.

[0015] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is used to store information including program instructions, and the processor is used to control the execution of the program instructions, and when the program instructions are loaded and executed by the processor, the steps of the chat room game loading method based on Android as described in the first aspect or any one of the possible implementation methods of the first aspect are implemented.

[0016] Beneficial effects:

[0017] 1. This solution integrates the Web Server in the client, so that the terminal where the client is located can be regarded as a local micro server. By sending a Web game download request to the server, it receives the Web game package issued by the server (the Web game package is developed based on the Cocos engine and exported to the Web format); then the downloaded Web game package is verified and decompressed, and then the Web game is loaded and displayed through the Web Server driver. By using the Cocos engine to develop games and exporting them to the Web format, they can be run on various Android devices, including older versions of devices. The client downloads, verifies and decompresses the Web game from the server to ensure that the new game content can be loaded and run smoothly on all Web-enabled devices. This method greatly improves the compatibility of the game and is not limited by Android version differences. In addition, by developing the game in the Web format and loading it through the Web Server driver, it allows for immediate adjustments and repairs when problems occur in the game content. The client downloads the latest Web game content without releasing a new version of the application. This method makes game updates and maintenance more flexible, reduces dependence on new version releases, reduces maintenance costs, and can quickly respond to user feedback and optimize.

[0018] 2. The Web Server integrated in the client includes the configured listening port and root directory. The Web game is deployed in the root directory of the Web Server. The Web Server listens to the HTTP request from the WebView in the client through the listening port. The Web Server parses the received HTTP request and searches for the corresponding Web game resources in the root directory to generate an HTTP response and return it to the WebView. The WebView receives the HTTP response returned by the Web Server, parses the Web game resources in the HTTP response, and then updates the interface and status of the Web game according to the Web game resources. In this way, the client can collect the user's operation information, and continuously send HTTP requests through WebView to continuously update the status and interface of the Web game, and realize the operation of the Web game in the chat room. The interaction between the Web Server and the client is realized through the interactive transmission of data between JavascriptInterface and HTML: by defining a class of JavascriptInterface interface and annotating it to be callable by JavaScript; binding the defined JavascriptInterface object to the WebView instance; calling the native method of Android by specifying the name (the name specified in the addJavascriptInterface method) in HTML / JavaScript, calling the JavaScript function through the evaluateJavascript method of WebView, and realizing the two-way communication between JavascriptInterface and HTML. In this way, the interaction between the Web Server and the local can be realized reliably, ensuring the smooth operation of the Web game.

[0019] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0021] Figure 1 A flowchart of a method for loading a game in a chat room based on Android provided in an embodiment of the present application.

[0022] Figure 2This is a block diagram of the structure of the Android-based chat room game loading device.

[0023] Icons: 10 - Android-based chat room game loading device; 11 - game request unit; 12 - game download unit; 13 - verification and decompression unit; 14 - game driver unit. DETAILED DESCRIPTION

[0024] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0025] In order to avoid the drawbacks of using native Android technology to develop interactive mini-games, this embodiment adopts the development form of Web games to develop games in chat rooms (chat rooms in social software). By integrating the Web Server in the client (parameters such as the listening port and root directory need to be configured, the listening port is used to listen to HTTP requests from the client, and the root directory is used to store game resources of the Web game), the terminal where the client is located can be regarded as a local micro server, and the Cocos engine is used to develop room interactive mini-games, and the games are exported to Web game packages in Web format (such as HTML5) and stored in the server (as the functions of the mini-games are enriched, more and more mini-games will be developed, and the server can form a game list based on the deployed Web game packages) for the client to download.

[0026] In this embodiment, for integrating the Web Server in the client, it is necessary not only to configure the parameters such as the listening port and the root directory, but also to configure the data interaction between the Web Server and the client to ensure that the operation of the Web game is driven by the Web Server. In this embodiment, the interaction between the Web Server and the client is realized by exchanging data through the JavascriptInterface and HTML.

[0027] Specifically, you can define a class of JavascriptInterface interface and annotate it to be callable by JavaScript (@JavascriptInterface annotation, declares that this method can be called by JavaScript). Then, bind the defined JavascriptInterface object to the WebView instance, call Android's native method by specifying the name in HTML / JavaScript, and call the JavaScript function through WebView's evaluateJavascript method to achieve two-way communication between JavascriptInterface and HTML. Here, the specified name is the name specified in the addJavascriptInterface method (addJavascriptInterface is a method of the WebView class, used to bind Java objects to the JavaScript environment of WebView).

[0028] After completing the development of the Web game and the deployment of the Web Server on the client, the following will take the client as the execution body to introduce in detail the method of loading games in the chat room based on Android.

[0029] See also Figure 1 , Figure 1 A flowchart of a method for loading a game in a chat room based on Android provided in an embodiment of the present application. In this embodiment, the method for loading a game in a chat room based on Android may include steps S10, S20, S30, and S40.

[0030] First, after the user enters the chat room, the chat room has a mini-game function, and the user can play such mini-games through the client. Accordingly, the client can execute step S10.

[0031] Step S10: Send a Web game download request to the server.

[0032] In this embodiment, the client can generate a Web game download request based on the user's operation and send it to the server.

[0033] Specifically, the client can generate a Web game list display request based on a user operation (such as clicking on a mini-game function) and send it to the server. After receiving the Web game list display request, the server can send Web game list data and display the Web game list through the client. The user can select the Web game he wants to play, and the client can generate a Web game download request based on the user's selection and send it to the server.

[0034] After receiving the Web game download request, the server can send the corresponding Web game package. At this time, the client can execute step S20.

[0035] Step S20: receiving a Web game package sent by the server, wherein the Web game package is developed based on the Cocos engine and exported to a Web format.

[0036] In this embodiment, the client can receive the Web game package sent by the server. The Web game package is developed based on the Cocos engine and exported to a Web format (such as HTML5) and stored in the server. The server can send the corresponding Web game package to the client based on the Web game download request sent by the client. Accordingly, the client can receive the Web game package sent by the server.

[0037] After downloading the Web game package sent by the server, the client can execute step S30.

[0038] Step S30: Verify and decompress the downloaded Web game package.

[0039] In this embodiment, the client can perform integrity check on the Web game package after the Web game package is downloaded. After the Web game package passes the integrity check, the client can decompress the Web game package.

[0040] After decompressing the Web game package, the client may execute step S40.

[0041] Step S40: Load and display the Web game through the Web Server driver.

[0042] In this embodiment, the client can deploy the decompressed Web game to the root directory of the Web Server, and the Web Server can monitor HTTP requests from the WebView in the client through the monitoring port (for example, HTTP requests to load the Web game entry page, or corresponding HTTP requests generated based on the user's game operations).

[0043] The Web Server can parse the received HTTP request and search for the corresponding Web game resources from the root directory to generate an HTTP response and return it to the WebView.

[0044] After WebView receives the HTTP response returned by the Web Server, it can parse it to obtain the Web game resources in the HTTP response, and then update the interface and status of the Web game based on the Web game resources.

[0045] WebView continuously sends HTTP, and the Web Server continuously responds and returns the corresponding Web game resources, thereby continuously updating the interface and status of the Web game and realizing the operation of the Web game.

[0046] This solution integrates the Web Server in the client, so that the terminal where the client is located can be regarded as a local micro server. By sending a Web game download request to the server, it receives the Web game package sent by the server (the Web game package is developed based on the Cocos engine and exported to the Web format); then the downloaded Web game package is verified and decompressed, and then the Web game is loaded and displayed through the Web Server driver. By using the Cocos engine to develop games and exporting them to the Web format, they can be run on various Android devices, including older versions of devices. The client downloads, verifies and decompresses the Web game from the server to ensure that the new game content can be loaded and run smoothly on all Web-enabled devices. This method greatly improves the compatibility of the game and is not limited by Android version differences. In addition, by developing the game in the Web format and loading it through the Web Server driver, it allows for immediate adjustments and repairs when problems occur in the game content. The client downloads the latest Web game content without releasing a new version of the application. This method makes game updates and maintenance more flexible, reduces dependence on new version releases, reduces maintenance costs, and can quickly respond to user feedback and optimize.

[0047] The Web Server integrated in the client includes the configured listening port and root directory. The Web game is deployed in the root directory of the WebServer. The Web Server listens to the HTTP request from the WebView in the client through the listening port. The WebServer parses the received HTTP request and searches for the corresponding Web game resources in the root directory to generate an HTTP response and return it to the WebView. The WebView receives the HTTP response returned by the Web Server, parses the Web game resources in the HTTP response, and then updates the interface and status of the Web game according to the Web game resources. In this way, the client can collect the user's operation information, and continuously send HTTP requests through the WebView to continuously update the status and interface of the Web game, and realize the operation of the Web game in the chat room.

[0048] The interaction between the Web Server and the client is achieved through the interactive data transmission between JavascriptInterface and HTML: by defining a JavascriptInterface class and annotating it to be callable by JavaScript; binding the defined JavascriptInterface object to the WebView instance; calling the Android native method by specifying the name (the name specified in the addJavascriptInterface method) in HTML / JavaScript, calling the JavaScript function through the evaluateJavascript method of WebView, and realizing the two-way communication between JavascriptInterface and HTML. In this way, the interaction between the Web Server and the local can be reliably realized, ensuring the smooth operation of the Web game.

[0049] Based on the same inventive concept, the embodiment of the present application further provides an Android-based chat room game loading device 10, wherein a Web Server is integrated in a client, and the Android-based chat room game loading device 10 is applied to the client, comprising:

[0050] The game request unit 11 is used to send a Web game download request to the server.

[0051] The game downloading unit 12 is used to receive a Web game package sent by a server, wherein the Web game package is developed based on the Cocos engine and exported to a Web format.

[0052] The verification and decompression unit 13 is used to verify and decompress the downloaded Web game package.

[0053] The game driving unit 14 is used to load and display the Web game through the Web Server driver.

[0054] In this embodiment, the game request unit 11 is specifically used to: generate a Web game list display request based on user operations and send it to the server; display the Web game list returned by the server; generate a Web game download request based on user selection and send it to the server.

[0055] In this embodiment, the Web Server integrated in the client includes a configured listening port and root directory, and the game driving unit 14 is specifically used to: deploy the Web game to the root directory of the Web Server; the Web Server listens to the HTTP request from the WebView in the client through the listening port; the Web Server parses the received HTTP request and searches for the corresponding Web game resources from the root directory to generate an HTTP response and return it to the WebView; the WebView receives the HTTP response returned by the WebServer, parses the Web game resources in the HTTP response, and then updates the interface and status of the Web game according to the Web game resources.

[0056] The present embodiment provides a storage medium, which is disposed in an electronic device and includes a stored program. When the program is running, the electronic device where the storage medium is located is controlled to execute the chat room game loading method based on Android of the present embodiment.

[0057] In addition, this embodiment also provides an electronic device (i.e., a terminal with a client installed, such as a smart phone, a tablet computer, etc.), including a memory and a processor, wherein the memory is used to store information including program instructions, and the processor is used to control the execution of the program instructions. When the program instructions are loaded and executed by the processor, the steps of the Android-based chat room game loading method of this embodiment are implemented.

[0058] In summary, the embodiment of the present application provides a method and device for loading games in a chat room based on Android, and integrates a Web Server in a client, so that the terminal where the client is located can be regarded as a local micro server, and a Web game package (the Web game package is developed based on the Cocos engine and exported to the Web format) issued by the server is received by sending a Web game download request to the server; then the downloaded Web game package is verified and decompressed, and then the Web game is loaded and displayed by the Web Server driver. By using the Cocos engine to develop games and exporting the games to the Web format, it can be run on various Android devices, including older versions of devices. The client downloads, verifies and decompresses the Web game from the server to ensure that the new game content can be smoothly loaded and run on all devices that support the Web. This method greatly improves the compatibility of the game and is not limited to Android version differences. In addition, by developing the game in the Web format and loading it through the Web Server driver, it allows for immediate adjustment and repair when problems occur in the game content. The client downloads the latest Web game content without releasing a new version of the application. This method makes game updates and maintenance more flexible, reduces dependence on new version releases, reduces maintenance costs, and can quickly respond to user feedback and optimize.

[0059] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0060] The units in the various embodiments of the present application may be integrated together to form an independent part, or each unit may exist independently, or two or more units may be integrated to form an independent part.

[0061] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0062] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for loading a game in a chat room based on Android, characterized in that: The client is integrated with a WebServer, and the method is applied to the client, including: Send a web game download request to the server; Receive the Web game package sent by the server, where the Web game package is developed based on the Cocos engine and exported to the Web format; Verify and decompress the downloaded web game package; Load and display web games through the Web Server driver.

2. The method for loading a game in a chat room based on Android according to claim 1, characterized in that: Send a web game download request to the server, including: Based on user operations, generate a Web game list display request and send it to the server; Display the list of web games returned by the server; Based on the user's selection, a Web game download request is generated and sent to the server.

3. The method for loading games in a chat room based on Android according to claim 1, characterized in that: The Web Server integrated in the client includes the configured listening port and root directory. It loads and displays Web games through the Web Server driver, including: Deploy the web game to the root directory of the web server; The Web Server listens to HTTP requests from the WebView in the client through the listening port; The Web Server parses the received HTTP request and searches for the corresponding Web game resources in the root directory to generate an HTTP response and return it to the WebView. WebView receives the HTTP response returned by the Web Server, parses the Web game resources in the HTTP response, and then updates the interface and status of the Web game based on the Web game resources.

4. The method for loading a game in a chat room based on Android according to claim 3, characterized in that: The interaction between WebServer and the client is achieved by transmitting data through JavascriptInterface and HTML.

5. The method for loading a game in a chat room based on Android according to claim 4, characterized in that: Transmit data through JavascriptInterface and HTML interaction, including: Define a class of JavascriptInterface interface and annotate it to be callable by JavaScript; Bind the defined JavascriptInterface object to the WebView instance; In HTML / JavaScript, the native method of Android is called by the specified name, and the JavaScript function is called by the evaluateJavascript method of WebView to realize the two-way communication between JavascriptInterface and HTML. The specified name is the name specified in the addJavascriptInterface method.

6. A chat room game loading device based on Android, characterized in that: The client is integrated with a WebServer, and the device is applied to the client, including: A game request unit, used to send a Web game download request to a server; A game download unit, used to receive a Web game package sent by a server, wherein the Web game package is developed based on the Cocos engine and exported to a Web format; Verification and decompression unit, used to verify and decompress the downloaded Web game package; The game driver unit is used to load and display Web games through the Web Server driver.

7. The method for loading a game in a chat room based on Android according to claim 6, characterized in that: The game request unit is specifically used to: Based on user operations, a Web game list display request is generated and sent to the server; the Web game list returned by the server is displayed; based on user selections, a Web game download request is generated and sent to the server.

8. The method for loading a game in a chat room based on Android according to claim 6, characterized in that: The Web Server integrated in the client includes the configured listening port and root directory, and the game driver unit, which is specifically used for: Deploy the Web game to the root directory of the Web Server; the Web Server listens to the HTTP request from the WebView in the client through the listening port; the Web Server parses the received HTTP request and searches for the corresponding Web game resources in the root directory to generate an HTTP response and return it to the WebView; the WebView receives the HTTP response returned by the Web Server, parses the Web game resources in the HTTP response, and then updates the interface and status of the Web game based on the Web game resources.

9. A storage medium, characterized in that: The storage medium is set in the electronic device, including a stored program, wherein when the program is running, the electronic device where the storage medium is located is controlled to execute the chat room game loading method based on Android according to any one of claims 1 to 5.

10. An electronic device comprising a memory and a processor, wherein the memory is used to store information including program instructions, and the processor is used to control the execution of the program instructions, characterized in that: When the program instructions are loaded and executed by the processor, the steps of the method for loading a chat room game based on Android described in any one of claims 1 to 5 are implemented.