Blind box machine real-time data synchronization method and system based on MQTT transparent transmission

By using MQTT pass-through technology and WebView bridging, the problems of data update delay and resource consumption of blind box machines were solved, achieving low-latency, high-reliability real-time data synchronization, improving user experience and reducing operation and maintenance costs.

CN121864808APending Publication Date: 2026-04-14ZHIDIAN HUIRONG TECHNOLOGY DEVELOPMENT (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-15
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing blind box machines suffer from data update delays, technical architecture limitations, insufficient network adaptability, and excessive resource consumption, resulting in poor user experience and increased maintenance costs.

Method used

By adopting MQTT pass-through technology, the IoT platform periodically polls the Redis cache of the Tencent Cloud SaaS platform, uses the existing MQTT long connection to send product change information to the blind box device, and refreshes the H5 page through WebView bridging technology to achieve low latency, high reliability and low resource consumption data synchronization.

Benefits of technology

It achieves real-time data synchronization for blind box machines with low latency, high reliability, cross-platform compatibility, and low resource consumption, improving user experience and reducing operation and maintenance costs. It adapts to complex network environments and balances development efficiency and operational performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121864808A_ABST
    Figure CN121864808A_ABST
Patent Text Reader

Abstract

The invention provides a blind box machine real-time data synchronization method and system based on MQTT transparent transmission, and an SaaS platform and an IoT platform are constructed on a Tencent cloud. The method comprises the steps that the SaaS platform detects whether commodity information is changed or not, a key-value is cached in redis, a main key of a commodity serves as the key, and the value is marked according to the change state of the commodity information; the IoT platform regularly polls the commodity change state cached by the redis, and if the commodity information is changed, the change information is acquired from the SaaS platform through the short connection; the IoT platform issues change information to specified blind box machine equipment through an MQTT protocol; and an APP client running on the blind box machine equipment receives the change information, and refreshes an H5 page through WebView bridging to realize commodity data updating. According to the method, the real-time data synchronization of the blind box machine with low delay, high reliability, cross-platform and low resource consumption can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of real-time communication technology, and in particular to a method and system for real-time data synchronization of blind box machines based on MQTT transparent transmission. Background Technology

[0002] With the development of new retail and IoT technologies, smart blind box machines, as a new type of automated vending machine, are widely deployed in shopping malls, cinemas, train stations, and other locations. Users access an H5 page through the touchscreen on the machine or by scanning a QR code with their mobile phones to browse and purchase products.

[0003] In practice, the prices and inventory information of goods in blind box machines change in real time. Typically, the blind box machine's on-device page periodically polls the SaaS interface to obtain the latest product information from the SaaS product management platform and refreshes the page. However, this information update method has the following problems: First, there's the issue of data update delays: traditional information updates rely on scheduled polling or manual triggering, which introduces significant delays. Users may see outdated information when making a purchase, leading to failed transactions or a poor experience. For example, if an item is sold out but the interface still shows it's available, users may only discover their purchase failed after completing the payment process, severely impacting the user experience.

[0004] Secondly, there are limitations in the technical architecture: existing technical solutions face a dilemma in architecture selection. If pure H5 technology is used, although development and maintenance are simple, it is impossible to establish an efficient real-time communication channel with the underlying device, making it difficult to achieve true real-time updates; if pure native APP is used, although it can be well integrated with the device, updates and iterations are difficult, requiring frequent releases of new versions, which increases maintenance costs.

[0005] Thirdly, there is the issue of network adaptability: Blind box machines are often deployed in locations with complex network environments, such as shopping malls and train stations. In weak or unstable network environments, existing solutions cannot guarantee the eventual consistency and reliability of data updates. In particular, when the network is restored after a brief interruption, data synchronization errors or omissions may occur.

[0006] Fourthly, there is the issue of resource consumption: To achieve relatively timely data synchronization, existing solutions typically employ short polling intervals, leading to frequent HTTP requests and increasing server load, device power consumption, and network traffic. This resource consumption problem is particularly pronounced for large-scale deployments of blind box device networks. Summary of the Invention

[0007] In view of this, the purpose of this application is to provide a method and system for real-time data synchronization of blind box machines based on MQTT pass-through. The IoT platform periodically polls the product change status in the Redis cache of the SaaS platform under the same Tencent Cloud. When the product information changes, the change information is obtained from the SaaS platform through a short connection and sent to the blind box machine device through the existing MQTT long connection to refresh the H5 page on the device. This method can achieve real-time data synchronization of blind box machines with low latency, high reliability, cross-platform compatibility, and low resource consumption.

[0008] In a first aspect, embodiments of this application provide a real-time data synchronization method for blind box machines based on MQTT transparent transmission, which builds a SaaS platform for product management and an IoT platform for device management on Tencent Cloud. The method includes: S1: The SaaS platform detects whether the product information of the blind box machine has changed, caches key-value pairs in Redis, uses the product primary key as the key, and marks the value according to the change status of the product information; S2: The IoT platform periodically polls the key-value cache in the Redis cache of the SaaS platform. If the value indicates that the product information has changed, the platform retrieves the change information from the SaaS platform via a short connection. S3: The IoT platform publishes change information to designated blind box machine devices via the MQTT protocol; S4: The APP client running on the blind box machine receives the change information; S5: The APP client uses WebView bridging technology to execute webview.reload to refresh the H5 page in order to update the product data.

[0009] In one possible implementation, in step S2, the short connection between the SaaS platform and the IoT platform is an HTTP short connection.

[0010] In one possible implementation, in step S3, the topic for publishing change information to the designated blind box device via the MQTT protocol carries the unique identifier of the blind box device. In one possible implementation, in step S4, the APP client verifies the received change information, including the legality of the message source and the integrity of the message.

[0011] Secondly, embodiments of this application provide a real-time data synchronization system for blind box machines based on MQTT transparent transmission. A SaaS platform for product management and an IoT platform for device management are built on Tencent Cloud. The system includes: The product information management module, set up on the SaaS platform, is used to detect whether the product information of the blind box machine has changed. It caches key-value pairs in Redis, using the product primary key as the key and marking the value according to the change status of the product information. The message routing module, set up on the IoT platform, is used to periodically poll the key-value pairs cached in Redis on the SaaS platform. If the value pairs indicate that the product information has changed, the module retrieves the change information from the SaaS platform via a short connection and publishes the change information to the designated blind box device via the MQTT protocol. The device communication module, located in the blind box device, is used to receive change information from the IoT platform via the MQTT protocol; The APP client module runs on the blind box device and has a built-in WebView component for rendering H5 pages and implementing WebView bridging to forward received change information to the H5 page; The H5 page module, embedded in the APP client, is used to display product information and update product data based on received change information.

[0012] In one possible implementation, the short connection between the SaaS platform and the IoT platform in the message routing module is an HTTP short connection.

[0013] In one possible implementation, the message routing module carries a unique identifier for the blind box device in the topic that publishes change information to the designated blind box device via the MQTT protocol. In one possible implementation, the APP client module is further configured to verify the received change information, including the legality of the message source and the integrity of the message.

[0014] Thirdly, embodiments of this application provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the real-time data synchronization method for blind box machines based on MQTT transparent transmission as described in any of the first aspects.

[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the real-time data synchronization method for blind box machines based on MQTT transparent transmission as described in any one of the first aspects.

[0016] The real-time data synchronization method and system for blind box machines based on MQTT pass-through provided in this application embodiment involves the IoT platform periodically polling the product change status in the Redis cache of the SaaS platform under the same Tencent Cloud. When product information changes, the system retrieves the change information from the SaaS platform via a short connection and sends the change information to the device via an existing MQTT long connection to refresh the H5 page on the blind box machine. This achieves low-latency, high-reliability, cross-platform, and low-resource-consumption real-time data synchronization for blind box machines. Furthermore, it employs WebView bridging technology, enabling communication between the native APP and the H5 embedded in WebView, balancing development efficiency and runtime performance, and achieving complementary advantages between native capabilities and Web technologies.

[0017] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 The flowchart illustrates a real-time data synchronization method for blind box machines based on MQTT transparent transmission provided in an embodiment of this application. Figure 2 This illustration shows a schematic diagram of a real-time data synchronization system for blind box machines based on MQTT transparent transmission, provided in an embodiment of this application. Figure 3 This paper illustrates an architecture diagram of a real-time data synchronization system for blind box machines based on MQTT transparent transmission, provided in an embodiment of this application. Figure 4 A schematic diagram of an electronic device provided in an embodiment of this application is shown. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0021] Currently, with the development of new retail and IoT technologies, smart blind box machines, as a new type of automated vending machine, are widely deployed in shopping malls, cinemas, stations, and other locations. Users access an H5 page through the touchscreen on the blind box machine or by scanning a QR code with their mobile phones to browse and purchase products. However, existing technologies have the following problems: First, there's the issue of data update delays: Traditional blind box machines rely on timed polling or manual triggering to update product prices, inventory, and other information, resulting in significant delays. Users may see outdated information when making a purchase, leading to failed transactions or a poor experience. For example, if an item is sold out but the interface still shows it's available, users may only discover their purchase failed after completing the payment process, severely impacting the user experience.

[0022] Secondly, there are limitations in the technical architecture: existing technical solutions face a dilemma in architecture selection. If pure H5 technology is used, although development and maintenance are simple, it is impossible to establish an efficient real-time communication channel with the underlying device, making it difficult to achieve true real-time updates; if pure native APP is used, although it can be well integrated with the device, updates and iterations are difficult, requiring frequent releases of new versions, which increases maintenance costs.

[0023] Thirdly, there is the issue of network adaptability: Blind box machines are often deployed in locations with complex network environments, such as shopping malls and train stations. In weak or unstable network environments, existing solutions cannot guarantee the eventual consistency and reliability of data updates. In particular, when the network is restored after a brief interruption, data synchronization errors or omissions may occur.

[0024] Fourthly, there is the issue of resource consumption: To achieve relatively timely data synchronization, existing solutions typically employ short polling intervals, leading to frequent HTTP requests and increasing server load, device power consumption, and network traffic. This resource consumption problem is particularly pronounced for large-scale deployments of blind box device networks.

[0025] Existing solutions update data through periodic polling, but suffer from significant update latency and high server load. To address this issue, a real-time data push method based on WebSocket was proposed, achieving better real-time performance. However, it lacks stability and compatibility in mobile network environments. Each WebSocket connection is a persistent TCP connection, which consumes a large amount of server memory and file descriptors when there are many concurrent connections. Furthermore, it does not resolve the collaboration issues between native apps and H5 pages. To address the aforementioned issues, this application provides a method and system for real-time data synchronization of blind box machines based on MQTT pass-through. The IoT platform periodically polls the product change status in the Redis cache of the SaaS platform under the same Tencent Cloud. When product information changes, the platform retrieves the change information from the SaaS platform via a short connection and sends it to the device via an existing MQTT long connection to refresh the H5 page on the blind box machine. This achieves low-latency, high-reliability, cross-platform compatibility, and low-resource-consumption real-time data synchronization for blind box machines. Furthermore, it employs WebView bridging technology, enabling communication between the native app and the H5 page embedded in the WebView, balancing development efficiency and runtime performance, and achieving a complementary advantage between native capabilities and Web technologies.

[0026] The technical solutions of this application will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. The components of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0027] To facilitate understanding of this embodiment, a real-time data synchronization method for blind box machines based on MQTT transparent transmission, disclosed in this application embodiment, will be described in detail first.

[0028] Transparent transmission mode is a technology that does not parse or process data content during data transmission. Its core lies in "transparency," meaning that from the sender to the receiver, intermediate devices only act as a "channel," neither modifying the data format nor interfering with the transmitted content. This mode is widely used in the Internet of Things (IoT), industrial control, smart homes, and other fields, and is the cornerstone of achieving efficient communication between devices. This application's embodiment adopts transparent transmission mode. After the IoT platform obtains change information from the SaaS platform, it sends the change information to the APP client running on the blind box device via an MQTT long connection. The APP client parses the received change message.

[0029] See Figure 1 As shown, Figure 1 A flowchart of a real-time data synchronization method for blind box machines based on MQTT transparent transmission provided in this application embodiment is included. The method includes the following steps: S1: The SaaS platform detects whether the product information of the blind box machine has changed, caches key-value pairs in Redis, uses the product primary key as the key, and marks the value according to the change status of the product information. SaaS (Software as a Service) is an application service delivery model for end users; IoT (Internet of Things) is a hub for connecting and managing IoT devices. In this embodiment, both a SaaS platform and an IoT platform are built on Tencent Cloud, belonging to different domains. The IoT platform is used for device management, and the SaaS platform is used for product management. The SaaS platform provides change detection services during product management, specifically detecting whether the product information (e.g., price, inventory, style, etc.) of the goods to be sold in the blind box machine has changed.

[0030] Redis (Remote Dictionary Server) is a key-value storage system. Key-value storage is a database that stores data in key-value pair format, where each key corresponds to a value. In this embodiment, the SaaS platform caches key-value pairs in Redis, using the product's primary key as the key. When the SaaS platform detects a change in product information, it marks the value as 1; otherwise, it marks it as 0. Specifically, product information is obtained via an HTTPS interface, for example, by retrieving inventory information from the blind box machine's inventory platform. When a change in product information is detected through the operation entry point, the value of the key in Redis is updated.

[0031] S2: The IoT platform periodically polls the key-value pairs cached in Redis on the SaaS platform. If the value pairs indicate that the product information has changed, the platform retrieves the change information from the SaaS platform via a short connection.

[0032] The basic idea of ​​timed polling is to use a timer to drive the scheduler to execute custom tasks according to a specified period. Polling interval management: Define a polling interval, which can be a fixed value or dynamically adjusted according to business needs. This interval determines the time interval between each polling session.

[0033] In this embodiment, the IoT platform periodically polls the key-value pairs cached in Redis on the SaaS platform. When key=1, indicating a change in product information, the IoT platform sends a request to the SaaS platform to retrieve the changed information. The SaaS platform responds to the request by sending the changed information back to the IoT platform via a short connection (e.g., an HTTP short connection). The IoT platform uses periodic polling to pull data, rather than the SaaS platform pushing data after detecting a change in product information. The polling period can be flexibly customized according to the scenario. A faster refresh frequency and a shorter polling period can be used when IoT platform resource usage is low, while a slower refresh frequency and a longer polling period can be used when IoT platform resource usage is high. A short connection refers to establishing a connection only when data needs to be sent during data transmission and closing the connection after data transmission is complete; that is, each connection only completes the transmission of one business function.

[0034] S3: The IoT platform publishes change information to designated blind box devices via the MQTT protocol.

[0035] MQTT (Message Queuing Telemetry Transport) is a communication protocol for the Internet of Things (IoT). The IoT platform and the blind box device already have an MQTT connection. The MQTT connection is a long connection, which can continuously send multiple data packets during the connection period. This application embodiment utilizes the existing MQTT long connection to publish change information to the blind box device.

[0036] The topic format for publishing change information via the MQTT protocol is as follows: The function `device / {deviceId} / product / update` is used to send messages to a specified blind box device, where `{deviceId}` is the unique identifier of the device.

[0037] S4: The APP client running on the blind box machine receives the change information. It's important to note that the MQTT protocol includes QoS (Quality of Service) mechanisms, message acknowledgment mechanisms, and intelligent degradation strategies. Upon receiving change information, the app client verifies the received information, checking the legitimacy of the message source and the message's integrity. Additionally, a degradation strategy is employed when the network is poor. This involves using existing technology to periodically poll the SaaS platform interface via the device's web interface to ensure business continuity. Alternatively, users can actively refresh the page using a refresh button.

[0038] S5: The APP client uses WebView bridging technology to execute webview.reload to refresh the H5 page in order to update the product data.

[0039] WebView Bridging: WebView is a component that embeds a browser engine within a native app to load and display web pages (HTML, CSS, JavaScript). H5, short for HTML5, is an advanced web page technology. Compared to H4, H5 offers more interactivity and functionality, and one of its biggest advantages is its support for multimedia on mobile devices.

[0040] In this embodiment, WebView bridging technology is used to enable the H5 page and the native app to communicate with each other and call each other's functions. webview.reload is the core refresh method of the WebView component, used to force a reload of the current page. It will re-request all resources and refresh the page content to update the blind box machine product information based on the received change information.

[0041] Executing JS / Reloading: Executing JS refers to actively calling and running JavaScript code within the WebView from within the native app code. This is a communication method between the native app and the H5 page; the native app sends data or instructions to the H5 page, and the H5's JS function receives and updates the page or executes business logic. Reloading refers to having the WebView reload the current URL or HTML content, equivalent to clicking the "refresh" button in a browser.

[0042] It should be noted that the APP client parses the received change message. Since this embodiment of the application uses a transparent transmission method, the data is not parsed during the data transmission process. Therefore, the APP client only completes the parsing of the change information at the end of the data transmission and executes the webview.reload of the WebView component to refresh the H5 page.

[0043] The real-time data synchronization method for blind box machines based on MQTT pass-through provided in this application involves the SaaS platform updating the product change status in the Redis cache after detecting a change in product information. The IoT platform periodically polls the product change status in the Redis cache. When a change is detected, the platform retrieves the change information from the SaaS platform via a short connection and sends the change information to the device's APP via an existing MQTT long connection. This application has the following advantages: 1. High Real-Time Performance: Compared to traditional polling methods (where the blind box device periodically polls the SaaS platform's interface), this embodiment uses an IoT platform to periodically poll the key change status in the SaaS platform's Redis cache. The polling period (milliseconds) can be flexibly customized according to the scenario. The IoT platform then sends the change information to the blind box device via existing MQTT (typically <3 seconds). This embodiment achieves end-to-end second-level data synchronization by flexibly configuring the polling period and leveraging the low latency and long connection advantages of the MQTT protocol. Compared to traditional polling solutions (typically over 30 seconds), this significantly improves real-time performance and greatly enhances the user experience. 2. High Reliability: Combining the MQTT protocol's QoS (Quality of Service) mechanism, message acknowledgment mechanism, and intelligent degradation strategy, reliable message delivery and business continuity are ensured under various network environments. Even in the event of network anomalies, basic data synchronization capabilities can be guaranteed through the degradation mechanism.

[0044] 3. Low resource consumption: It adopts a publish / subscribe model, and only publishes and subscribes to the status of changes in product information. The status subscription here interacts through the intranet of the cloud platform (both the SaaS platform and the IoT platform belong to Tencent Cloud), avoiding external network communication between the device and the cloud service. Therefore, communication traffic is only generated when product data changes. Compared with the fixed interval polling method, it can reduce network traffic by more than 80%, while reducing server pressure and device power consumption.

[0045] 4. Excellent compatibility and maintainability: H5 pages facilitate rapid iteration and cross-platform deployment, while core communication logic is guaranteed by the native app, balancing development efficiency and runtime performance. Through WebView bridging technology, the advantages of native capabilities and web technologies are complemented. 5. Strong scalability: This architecture can be easily extended to other scenarios that require real-time synchronization, such as advertising content updates, device status monitoring, remote command issuance, and emergency notification push, and has broad application prospects. 6. Intelligent Adaptability: Through intelligent polling degradation mechanism and dynamic message merging strategy, the system can automatically optimize performance according to actual operating conditions, maximizing resource utilization while ensuring real-time performance.

[0046] 7. Compared to the traditional method of establishing a long connection between the blind box machine device and the SaaS platform via WebSocket, and the blind box machine device periodically polling the SaaS platform's interface, the implementation method of this application is lightweight, the device and the cloud are decoupled, and the polling cycle can be flexibly customized according to the scenario.

[0047] Based on the same inventive concept, this application also provides a real-time data synchronization system for blind box machines based on MQTT pass-through, which corresponds to the real-time data synchronization method for blind box machines based on MQTT pass-through. Since the principle of the device in this application is similar to the real-time data synchronization method for blind box machines based on MQTT pass-through described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0048] See Figure 2 As shown, Figure 2 This is a schematic diagram of the structure of a real-time data synchronization system for blind box machines based on MQTT transparent transmission provided in an embodiment of this application. A SaaS platform for product management and an IoT platform for device management are built on Tencent Cloud. The system includes: The product information management module 201 is set up on the SaaS platform and is used to detect whether the product information of the blind box machine has changed. It caches key-value pairs in Redis, using the product primary key as the key and marking the value according to the change status of the product information. The message routing module 202 is set on the IoT platform and is used to periodically poll the key-value cache of the SaaS platform's Redis. If the value indicates that the product information has changed, the module retrieves the change information from the SaaS platform through a short connection and publishes the change information to the designated blind box device through the MQTT protocol. The device communication module 203 is installed in the blind box machine and is used to receive change information from the IoT platform via the MQTT protocol. The APP client module 204 runs on the blind box machine device. It has a built-in WebView component for rendering H5 pages and implementing WebView bridging to forward received change information to the H5 page. H5 page module 205, embedded in the APP client, is used to display product information and update product data based on received change information.

[0049] Optionally, the device communication module 203 is the same as the APP client module 204.

[0050] In one possible implementation, the short connection between the SaaS platform and the IoT platform in the message routing module 202 is an HTTP short connection.

[0051] In one possible implementation, the message routing module 202 carries the unique identifier of the blind box device in the topic of publishing change information to the designated blind box device via the MQTT protocol. In one possible implementation, the APP client module 204 is further configured to verify the received change information, including the legality of the message source and the integrity of the message.

[0052] The real-time data synchronization system for blind box machines based on MQTT pass-through provided in this application embodiment involves the IoT platform periodically polling the product change status in the Redis cache of the SaaS platform under the same Tencent Cloud. When product information changes, the system retrieves the change information from the SaaS platform via a short connection and sends the change information to the device via an existing MQTT long connection to refresh the H5 page on the blind box machine. This achieves low-latency, high-reliability, cross-platform, and low-resource-consumption real-time data synchronization for blind box machines. Furthermore, it employs WebView bridging technology, enabling communication between the native APP and the H5 embedded in WebView, balancing development efficiency and runtime performance, and achieving complementary advantages between native capabilities and Web technologies.

[0053] See Figure 3 As shown, Figure 3 This application provides an architecture diagram of a real-time data synchronization system for blind box machines based on MQTT transparent transmission, which is an embodiment of the present application. Figure 3In this context, the SaaS platform is used for product management and can provide change detection services. It retrieves product information through the HTTP(S) API interface. When a change in product information is detected, the IoT platform obtains the change information from the SaaS platform via a short HTTP connection. Here, HTTP POST is a specific HTTP request method. The IoT platform is used for device management. MQTT works based on the publish-subscribe model. During communication, the MQTT protocol has three roles: publisher, broker, and subscriber. The IoT platform forwards change information to the blind box machine's APP client through a long MQTT connection. It uses WebView bridging technology to execute JS / overload, actively calling and running the JavaScript code in the WebView. The APP client sends the change information to the H5 page to update the H5 page. The user then interacts with the H5 page to purchase products from the blind box machine.

[0054] See Figure 4 As shown, Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of this application. The electronic device 400 includes a processor 401, a memory 402, and a bus 403. The memory 402 stores machine-readable instructions that can be executed by the processor 401. When the electronic device is running, the processor 401 communicates with the memory 402 through the bus 403. The processor 401 executes the machine-readable instructions to perform the steps of the real-time data synchronization method for blind box machines based on MQTT pass-through as described above.

[0055] Specifically, the memory 402 and processor 401 mentioned above can be general-purpose memory and processor, without any specific limitations. When the processor 401 runs the computer program stored in the memory 402, it can execute the above-mentioned real-time data synchronization method for blind box machines based on MQTT transparent transmission.

[0056] Corresponding to the above-mentioned real-time data synchronization method for blind box machines based on MQTT pass-through, this application embodiment also provides a computer-readable storage medium storing a computer program, which is executed by a processor to perform the steps of the above-mentioned real-time data synchronization method for blind box machines based on MQTT pass-through.

[0057] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or modules may be electrical, mechanical, or other forms.

[0058] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0059] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.

[0060] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0061] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for real-time data synchronization of blind box machines based on MQTT transparent transmission, characterized in that, The method for building a SaaS platform for product management and an IoT platform for device management on Tencent Cloud includes: S1: The SaaS platform detects whether the product information of the blind box machine has changed, caches key-value pairs in Redis, uses the product primary key as the key, and marks the value according to the change status of the product information; S2: The IoT platform periodically polls the key-value cache in the Redis cache of the SaaS platform. If the value indicates that the product information has changed, the platform retrieves the change information from the SaaS platform via a short connection. S3: The IoT platform publishes change information to designated blind box machine devices via the MQTT protocol; S4: The APP client running on the blind box machine receives the change information; S5: The APP client uses WebView bridging technology to execute webview.reload to refresh the H5 page in order to update the product data.

2. The real-time data synchronization method for blind box machines based on MQTT transparent transmission according to claim 1, characterized in that, In step S2, the short connection between the SaaS platform and the IoT platform is an HTTP short connection.

3. The real-time data synchronization method for blind box machines based on MQTT transparent transmission according to claim 1, characterized in that, In step S3, the unique identifier of the blind box machine is carried in the subject that publishes change information to the designated blind box machine device via the MQTT protocol.

4. The real-time data synchronization method for blind box machines based on MQTT transparent transmission according to claim 1, characterized in that, In step S4, the APP client verifies the received change information, including the legality of the message source and the integrity of the message.

5. A real-time data synchronization system for blind box machines based on MQTT transparent transmission, characterized in that, A SaaS platform for product management and an IoT platform for device management are built on Tencent Cloud. The system includes: The product information management module, set up on the SaaS platform, is used to detect whether the product information of the blind box machine has changed. It caches key-value pairs in Redis, using the product primary key as the key and marking the value according to the change status of the product information. The message routing module, set up on the IoT platform, is used to periodically poll the key-value pairs cached in Redis on the SaaS platform. If the value pairs indicate that the product information has changed, the module retrieves the change information from the SaaS platform via a short connection and publishes the change information to the designated blind box device via the MQTT protocol. The device communication module, located in the blind box device, is used to receive change information from the IoT platform via the MQTT protocol; The APP client module runs on the blind box device and has a built-in WebView component for rendering H5 pages and implementing WebView bridging to forward received change information to the H5 page; The H5 page module, embedded in the APP client, is used to display product information and update product data based on received change information.

6. The real-time data synchronization system for blind box machines based on MQTT transparent transmission according to claim 5, characterized in that, In the message routing module, the short connection between the SaaS platform and the IoT platform is an HTTP short connection.

7. The real-time data synchronization system for blind box machines based on MQTT transparent transmission according to claim 5, characterized in that, In the message routing module, the topic for publishing change information to the designated blind box device via the MQTT protocol carries the unique identifier of the blind box device.

8. The real-time data synchronization system for blind box machines based on MQTT transparent transmission according to claim 5, characterized in that, The APP client module is also used to verify the received change information, including the legality of the message source and the integrity of the message.

9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. The processor executes the machine-readable instructions to perform the steps of the real-time data synchronization method for blind box machines based on MQTT pass-through as described in any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the real-time data synchronization method for blind box machines based on MQTT transparent transmission as described in any one of claims 1 to 4.