CN114048042A - Event notification method and device, electronic equipment and storage medium - Google Patents

Event notification method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114048042A
CN114048042A CN202111155112.0A CN202111155112A CN114048042A CN 114048042 A CN114048042 A CN 114048042A CN 202111155112 A CN202111155112 A CN 202111155112A CN 114048042 A CN114048042 A CN 114048042A
Authority
CN
China
Prior art keywords
event
consumer
instruction
provider
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111155112.0A
Other languages
Chinese (zh)
Inventor
吴贯亮
张赛
曹云轩
方昌权
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202111155112.0A priority Critical patent/CN114048042A/en
Publication of CN114048042A publication Critical patent/CN114048042A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Multimedia (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The present disclosure relates to an event notification method, an event notification apparatus, an electronic device, and a storage medium, including: the method comprises the steps of receiving an event triggering instruction sent by an event provider, wherein the event triggering instruction comprises an event identifier of a target event, the event triggering instruction represents that the target event is triggered and generated at the event provider, determining an event consumer monitoring the target event based on the event identifier, and sending an event callback instruction to the event consumer, wherein the event callback instruction comprises the event identifier, the event callback instruction is used for notifying the event consumer, and the target event is triggered and generated at the event provider. According to the method and the device, when any target event occurs at the event provider, the event center system can be informed actively through the event trigger instruction, and then the event consumer monitoring the target event is informed, so that the event provider can inform actively, and meanwhile the informing efficiency is improved.

Description

Event notification method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of internet technologies, and in particular, to an event notification method and apparatus, an electronic device, and a storage medium.
Background
With the rapid development of the current mobile internet, along with the popularization of a mobile terminal and the development of an H5 technology, developers increasingly and urgently need a communication mode between a non-active H5 page and a localized application, so as to realize the use and the expansion of capabilities of terminal state change, including App switching between a front state and a back state, App suspending and recovering, App network change, App user login and logout and the like.
After a communication mode taking Bridge as a channel is constructed between the H5 page and the localized application, the interaction between the H5 page and the localized application is realized, and most interaction scenes are met, however, a class of scenes still cannot be met in this way, namely the above-mentioned scene of end state change exists. For example, when the H5 page needs to determine whether some events (whether end states change) have occurred in the localized application, the H5 page needs to call the bridge corresponding to the events to poll the localized application to determine whether the events have occurred, which is obviously passive, and the polling method also means that a lot of time is consumed to occupy channel resources.
Disclosure of Invention
The present disclosure provides an event notification method, an event notification apparatus, an electronic device, and a storage medium, and the technical solution of the present disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided an event notification method, including:
receiving an event trigger instruction sent by an event provider; the event trigger instruction comprises an event identifier of a target event; the event trigger instruction represents that a target event is triggered and generated at an event provider;
determining an event consumer listening to the target event based on the event identification;
sending an event callback instruction to an event consumer; the event callback instruction comprises an event identifier; the event callback instruction is used for notifying an event consumer that a target event is triggered to be generated at an event provider.
In some possible embodiments, when the event provider includes a first event provider and a second event provider, receiving the event trigger instruction sent by the event provider includes:
receiving a first event trigger instruction sent by a first event provider through a first interface; the first event trigger instruction comprises an event identification of a first target event;
receiving a second event trigger instruction sent by a second event provider through a first interface; the second event trigger instruction comprises an event identification of the second target event.
In some possible embodiments, before receiving the event triggering instruction sent by the event provider, the method further includes:
receiving an event registration instruction sent by an event provider; the event registration instruction comprises an event identifier and event description information of the target event;
receiving an event monitoring instruction sent by an event consumer; the event monitoring instruction comprises description information of an event to be monitored;
and if the description information of the event to be monitored is matched with the event description information of the target event, determining the event consumer as the event consumer for monitoring the target event.
In some possible embodiments, determining the event consumer as the event consumer listening for the target event comprises:
and establishing a mapping relation between the event identifier of the target event and the event consumer.
In some possible embodiments, receiving the event registration instruction sent by the event provider comprises:
receiving a first event registration instruction sent by a first event provider through a second interface; the first event registration instruction comprises an event identification and first event description information of a first target event;
receiving a second event registration instruction sent by a second event provider through a second interface; the second event registration instruction includes an event identification of the second target event and second event description information.
In some possible embodiments, the event listening instruction further comprises a callback function of the event consumer;
sending the event callback instruction to the event consumer comprises:
and sending an event callback instruction to the event consumer based on the callback function of the event consumer.
In some possible embodiments, when the event consumer of the target event is a plurality of event consumers, sending the event callback instruction to the event consumer includes:
determining currently available communication resources;
determining a sending strategy of event callback instructions of a plurality of event consumers based on the currently available communication resources;
and sending an event callback instruction to a plurality of event consumers based on the sending strategy.
In some possible embodiments, the event provider and the event consumer are located in the same application program, the event notification method is applied to an event center system, and the event center system is carried by the event provider or the event consumer;
the application program is hybrid App.
According to a second aspect of the embodiments of the present disclosure, there is provided an event notification apparatus including:
the instruction receiving module is configured to execute an event triggering instruction sent by the event providing party; the event trigger instruction comprises an event identifier of a target event; the event trigger instruction represents that a target event is triggered and generated at an event provider;
a consumer determination module configured to perform determining an event consumer listening to the target event based on the event identification;
the instruction sending module is configured to execute sending of an event callback instruction to an event consumer; the event callback instruction comprises an event identifier; the event callback instruction is used for notifying an event consumer that a target event is triggered to be generated at an event provider.
In some possible embodiments, when the event provider comprises a first event provider and a second event provider, the instruction receiving module is configured to perform:
receiving a first event trigger instruction sent by a first event provider through a first interface; the first event trigger instruction comprises an event identification of a first target event;
receiving a second event trigger instruction sent by a second event provider through a first interface; the second event trigger instruction comprises an event identification of the second target event.
In some of the possible embodiments of the present invention,
the instruction receiving module is configured to execute an event registration instruction sent by the event provider; the event registration instruction comprises an event identifier and event description information of the target event; receiving an event monitoring instruction sent by an event consumer; the event monitoring instruction comprises description information of an event to be monitored;
and the consumer determining module is configured to execute the step of determining that the event consumer is the event consumer for monitoring the target event if the description information of the event to be monitored is matched with the event description information of the target event.
In some possible embodiments, the consumer determination module is configured to perform:
and establishing a mapping relation between the event identifier of the target event and the event consumer.
In some possible embodiments, the instruction receiving module is configured to perform: receiving a first event registration instruction sent by a first event provider through a second interface; the first event registration instruction comprises an event identification and first event description information of a first target event;
receiving a second event registration instruction sent by a second event provider through a second interface; the second event registration instruction includes an event identification of the second target event and second event description information.
In some possible embodiments, the event listening instruction further comprises a callback function of the event consumer;
an instruction sending module configured to perform:
and sending an event callback instruction to the event consumer based on the callback function of the event consumer.
In some possible embodiments, when the event consumer of the target event is a plurality of event consumers, the instruction sending module is configured to perform:
determining currently available communication resources;
determining a sending strategy of event callback instructions of a plurality of event consumers based on the currently available communication resources;
and sending an event callback instruction to a plurality of event consumers based on the sending strategy.
In some possible embodiments, the event provider and the event consumer are located in the same application program, the event notification device is applied to an event center system, and the event center system is carried by the event provider or the event consumer;
the application program is hybrid App.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of any one of the first aspect as described above.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform the method of any one of the first aspects of the embodiments of the present disclosure.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising a computer program, the computer program being stored in a readable storage medium, from which at least one processor of a computer device reads and executes the computer program, causing the computer device to perform the method of any one of the first aspects of embodiments of the present disclosure.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
the method comprises the steps of receiving an event triggering instruction sent by an event provider, wherein the event triggering instruction comprises an event identifier of a target event, the event triggering instruction represents that the target event is triggered and generated at the event provider, determining an event consumer monitoring the target event based on the event identifier, and sending an event callback instruction to the event consumer, wherein the event callback instruction comprises the event identifier, the event callback instruction is used for notifying the event consumer, and the target event is triggered and generated at the event provider. According to the method and the device, when any target event occurs at the event provider, the event center system can be informed actively through the event trigger instruction, and then the event consumer monitoring the target event is informed, so that the event provider can inform actively, and meanwhile the informing efficiency is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a schematic diagram illustrating an application environment in accordance with an illustrative embodiment;
FIG. 2 is a flow diagram illustrating a method of event notification in accordance with an exemplary embodiment;
FIG. 3 is a flow diagram illustrating a method of event notification in accordance with an exemplary embodiment;
FIG. 4 is a flow diagram illustrating a method of determining to send an event callback instruction in accordance with an illustrative embodiment;
FIG. 5 is a schematic diagram illustrating an event proactive notification in accordance with an exemplary embodiment;
FIG. 6 is a block diagram illustrating an event notification apparatus in accordance with an exemplary embodiment;
FIG. 7 is a block diagram illustrating an electronic device for event notification in accordance with an exemplary embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
All data about a user in the present application are data authorized by the user.
Referring to fig. 1, fig. 1 is a schematic diagram illustrating an application environment of an event notification method according to an exemplary embodiment, and as shown in fig. 1, the application environment may include a client 01, an event provider 011 located in an application of the client 01, an event center system 012, and an event consumer 013.
In some possible embodiments, the client 01 may include, but is not limited to, a smartphone, a desktop computer, a tablet computer, a laptop computer, a smart speaker, a digital assistant, an Augmented Reality (AR)/Virtual Reality (VR) device, a smart wearable device, and the like. The software running on the client may also be an application program, an applet, or the like. Alternatively, the operating system running on the client may include, but is not limited to, an android system, an IOS system, linux, windows, Unix, and the like.
The event provider 011, the event center system 012, and the event consumer 013 may belong to the same application function of the client 01.
In some possible embodiments, the event center system 012 may receive an event trigger instruction sent by the event provider 011, where the event trigger instruction includes an event identifier of a target event, the event trigger instruction characterizes that the target event has been triggered to generate at the event provider 011, and determines an event consumer listening to the target event based on the event identifier, and sends an event callback instruction to the event consumer 013, the event callback instruction includes an event identifier, and the event callback instruction is used for notifying the event consumer that the target event has been triggered to generate at the event provider 011.
Fig. 2 is a flowchart illustrating an event notification method according to an exemplary embodiment, where as shown in fig. 2, the event notification method may be applied to a client and may also be applied to other node devices, and includes the following steps:
in step S201, an event trigger instruction sent by an event provider is received; the event trigger instruction comprises an event identifier of a target event; the event trigger instruction characterizes that the target event is triggered to be generated at an event provider.
The implementation subjects of the schemes and the specific embodiments related to steps S201 to S205 may be the event center system. In the embodiment of the present application, the event center system is located in the client and is configured to manage all event operations, including event registration, event monitoring, event triggering, and event notification. The event center is a single instance, and can be specifically located between an event provider and an event consumer on a logical chain, namely, the event center serves as a medium for the event provider and the event consumer and supports mutual communication of the two parties.
In some possible embodiments, the event provider and the event consumer may be located in different devices, such as the event provider being located in a client and the event consumer being located in a server; or the event provider is positioned in the server, and the event consumption direction is positioned in the client; or the event provider and the event consumer are located in different clients; alternatively, the event provider and the event consumer may be located in different servers. In this state, the event center system may be a device separate from the event provider and the event consumer, or may belong to the same device as the event provider, or may belong to the same device as the event consumer.
In some possible embodiments, the event provider and the event consumer may belong to the same device, for example, to the same client, or to the same server. Taking the case that the event provider and the event consumer belong to the same client, the event provider and the event consumer may be different applications on the client, in this case, the event center system may be another application independent of the event provider and the event consumer, or may belong to the same application as the event provider, or may belong to the same application as the event consumer. Optionally, the application program corresponding to the event provider, the event consumer, or the event center system may be any one of a localized application (Native App, NA), a Web application (Web App), or a hybrid application (h-event consumer bridge App).
In the embodiment of the application, the localized application refers to a third-party application program which is written and operated by using a native program based on a local operating system of a smart phone, such as iOS, Android, and WP. A web application is an application software operating on the internet or an intranet using a web browser, and is an application program written in a web language (e.g., programming languages such as HTML, JavaScript, Java, etc.) and needs to be executed through the web browser, such as H5 page. Hybrid applications include localized applications and web applications (H5 pages) developed by developers.
In some possible embodiments, the event provider and the event consumer may belong to a single application, which may be any one of a localized application, a web-based application, or a hybrid application. When the application is a hybrid application, the event provider may be an H5 page and the event consumer may be a localized application, or the event provider may be a localized application and the event consumer may be an H5 page. Optionally, the event center system may be integrated with the localized application or integrated with the H5 page, i.e., the event center system may be hosted by the event provider or the event consumer.
In the following, an example is described in which the event provider and the event consumer belong to the same application on the same device, the event provider is a localized application, and the event consumer is an H5 page, and specific steps of other embodiments refer to the above embodiments, and will not be described again here.
In the embodiment of the present application, an event center system receives an event trigger instruction sent by an event provider, where the event trigger instruction includes an event identifier of a target event, and the event trigger instruction characterizes that the target event has been triggered and generated by the event provider, and the event provider is a localized application, and an event consumer is an H5 page, and is substituted into the event provider, so that: the event center system receives an event triggering instruction sent by an event provider, wherein the event triggering instruction comprises an event identifier of a target event, and the event triggering instruction indicates that the target event is triggered and generated at the event provider.
Optionally, the target event may be the use and extension of the capability of changing the end state, including application switching between front and back, application suspension recovery, application network change, application user login and logout, application switching between the dark mode, entry of the current page on the localized application side, exit of the web page view on the localized application side, and completion of loading the web page view on the localized application side.
For example, assuming that the power of the client is reduced to 30% for the target event, the event description information of the target event may be the power of the client is reduced to 30%, and the identifier of the target event may be a symbol uniquely identifying the target event, such as 0001, jhghhj65, etc.
Optionally, when the event provider detects that the target event has occurred, such as the client power has dropped to 30%, an event trigger instruction may be sent to the event center system. Optionally, when the event provider receives a prompt message including information that the power of the client has decreased to 30%, it may be determined that the target event has been triggered to occur, and an event triggering instruction is sent to the event center system.
In the embodiment of the application, after receiving the event triggering instruction sent by the event provider, the event center system needs to send an event callback instruction to the event consumer, so as to inform the event consumer that the target event is triggered and generated by the event provider. However, there may be countless events in an application, and any two events (such as the power of the client is reduced to 30% and the memory of the client is only 10%) may be independent, so that the event center system can receive an event trigger instruction sent by some event provider about a target event, which may be registered in the event center system. Similarly, the event center system can send an event callback instruction to the event consumer to inform the event consumer that the target event has been triggered to be generated at the event provider because the event consumer listens to the target event.
In some possible embodiments, the event provider may implement registration of the target event through the event center system, so that when the target event occurs at the event provider, the event provider can send an event trigger instruction to the event center system, and the event consumer may implement listening to the target event through the event center system, so that after the event center system receives the event trigger instruction about the target event sent by the event provider, the event consumer can send an event callback instruction to the event consumer. FIG. 3 is a flow chart illustrating a method of event notification according to an exemplary embodiment, as shown in FIG. 3, including the steps of:
in step S301, an event registration instruction sent by an event provider is received; the event registration instruction includes event identification and event description information of the target event.
In the embodiment of the application, an event center system receives an event registration instruction sent by an event provider, wherein the event registration instruction comprises an event identifier and event description information of a target event. Based on that the target event is that the electric quantity of the client is reduced to 30%, the explanation is continued, after the event center system receives an event registration instruction sent by an event provider, the event registration instruction can be analyzed, the event identifier of the target event can be obtained to be 0001, and the event description information is that the electric quantity of the client is reduced to 30%, and then the event center system can store the event identifier and the event description information of the target event.
Optionally, only the event description information may be present in the event registration instruction, the event identifier may be assigned to the target event by the event center system, and after determining the event identifier, the event identifier may be sent to the event provider.
In step S303, an event monitoring instruction sent by an event consumer is received, where the event monitoring instruction includes description information of an event to be monitored.
In step S305, if the description information of the event to be monitored matches the event description information of the target event, it is determined that the event consumer is the event consumer who monitors the target event.
In an alternative embodiment, the event center system receives an event monitoring instruction sent by an event consumer, wherein the event monitoring instruction comprises description information of an event to be monitored. If the description information of the event to be monitored is matched with the event description information of the target event, for example, if the description information of the event to be monitored is "power down to 30%", the description information of the event to be monitored can be successfully matched with the event description information of the target event, and then it can be determined that the event consumer who sends the event monitoring instruction is the event consumer who monitors the target event.
Optionally, when determining that the event consumer sending the event monitoring instruction is the event consumer monitoring the target event, the event center system may establish a mapping relationship between the event identifier of the target event and the event consumer sending the event monitoring instruction, so that when the event provider detects that the target event has been triggered, for example, the electric quantity of the client has decreased to 30%, the event center system may send the event triggering instruction, and after determining the event identifier of the target event from the event triggering instruction, the event center system may determine the event consumer corresponding to the target event directly based on the mapping relationship between the event identifier and the event consumer.
In an alternative embodiment, the mapping relationship between the event identifier of the target event and the event consumer sending the event listening instruction may be represented by a mapping table, as shown in table (1):
table (1): mapping table of event identification and event consumer
Figure RE-GDA0003469292150000091
As can be seen from table (1), there may be a plurality of target events (target event a, target event B, and target event C), and different target events may belong to different event providers or may belong to the same event provider. Each target event can be registered in the event center system by the event provider to which the target event belongs by sending an event registration instruction. Wherein, different target events can have different event identifications (0001,0002, 0003) and event description information (not shown in the table). If an event consumer wants to subscribe to an event, the event consumer can determine that the event consumer is a listener of a target event corresponding to event description information by sending an event monitoring instruction when the description information of the event to be monitored provided by the event consumer can be successfully matched with the event description information, so that the event center system can establish a relationship between the event consumer and the event identifier of the target event, and as can be seen from table (1), the event consumer a, the event consumer B and the event consumer C are listeners of the target event a, the event consumer B and the event consumer H are listeners of the target event B, and the event consumer C is a listener of the target event C. Alternatively, a target event may be composed of any number of event consumers, and an event consumer may also listen to multiple target events, depending on the needs of the event consumers.
Therefore, according to the embodiment of the application, when any target event occurs at the event provider, the event consumer who monitors the target event can be notified through the event center system, and the notification efficiency is improved while the event provider is ensured to actively notify.
Since there may be multiple event providers in the embodiment of the present application, such as a first event provider and a second event provider, even including a third event provider and a fourth event provider, when each event provider sends an event trigger instruction to the event center system, the event trigger instruction needs to be sent to the event center system through an interface. Based on this, multiple event providers may send an event trigger instruction to the event center system through the same interface, for example, the event center system may receive, through the first interface, a first event trigger instruction sent by a first event provider, where the first event trigger instruction includes an event identifier of a first target event, and also receive, through the first interface, a second event trigger instruction sent by a second event provider, where the second event trigger instruction includes an event identifier of a second target event.
Similarly, since there may be a plurality of event providers in the embodiment of the present application, such as a first event provider and a second event provider, even including a third event provider and a fourth event provider, when each event provider sends an event registration instruction to the event center system, the event registration instruction needs to be sent to the event center system through an interface. Based on this, the plurality of event providers may send the event registration instruction to the event center system through the same interface, for example, the event center system may receive, through the second interface, the first event registration instruction sent by the first event provider, where the first event registration instruction includes the event identifier and the first event description information of the first target event. A second event registration instruction sent by a second event provider may also be received through the second interface, where the second event registration instruction includes an event identifier and second event description information of a second target event.
Similarly, since there may be a plurality of event consumers in the embodiment of the present application, such as the first event consumer and the second event consumer, even including the third event consumer and the fourth event consumer, when each event consumer sends an event monitoring instruction to the event center system, the event monitoring instruction needs to be sent to the event center system through an interface, and if each event consumer corresponds to one interface, a large amount of resource consumption is inevitably caused. Based on this, the event consumers may send the event monitoring instruction to the event center system through the same interface, for example, the event center system may receive the first event monitoring instruction sent by the first event consumer through the third interface, where the first event monitoring instruction includes description information of the first event to be monitored. And a second event monitoring instruction sent by a second event consumer can be received through the third interface, wherein the second event monitoring instruction comprises the description information of a second event to be monitored.
Therefore, the consumption of interface resources is saved through the unified interface, and because the event registration is carried out through the unified interface, the event monitoring and the event triggering are carried out, so that the problem that in the prior art, an event consumer needs to call a corresponding interface or a bridge to acquire a structure in a polling mode because whether a certain target event occurs in an event provider or not can be avoided, and the purpose of saving time is further achieved.
In step S203, an event consumer listening to the target event is determined based on the event identification.
In this embodiment of the application, the event center system may determine, based on the event identifier, an event consumer that monitors the target event, and set forth with reference to table (1), when the event center system receives the event trigger instruction sent by the event provider, the event trigger instruction may be analyzed, and if the event identifier obtained through the analysis is 0001, it may be determined that the event consumer corresponding to 0001 is event consumer a, event consumer B, and event consumer C.
In step S205, an event callback instruction is sent to the event consumer; the event callback instruction comprises an event identifier; the event callback instruction is used for notifying an event consumer that a target event is triggered to be generated at an event provider.
Since an event consumer may listen for multiple target events, when the event center system determines that a target event to be listened to occurs in an event provider, an event callback instruction including an event identifier may be sent to the event consumer to notify, for example, that the target event corresponding to event consumer a, event consumer B, and event consumer C, 0001 has occurred in its corresponding event provider.
In order to enable the event center system to quickly notify an event consumer who monitors a certain target event after receiving an event trigger instruction corresponding to the target event, when each event consumer sends an event monitoring instruction to the event center system, the event monitoring instruction further comprises a callback function of the event consumer, so that the event center system can store the callback function of the event consumer, and when the event center system sends the event callback instruction to the event consumer, the event center system can send the event callback instruction to the event consumer based on the callback function of the event consumer.
When the event consumer of the target event is multiple event consumers, a method for sending an event callback instruction may also be determined based on currently available communication resources, fig. 4 is a flowchart illustrating a method for determining to send an event callback instruction according to an exemplary embodiment, as shown in fig. 4, including the following steps:
in step S2051, currently available communication resources are determined.
In step S2053, a sending policy of event callback instructions of a plurality of event consumers is determined based on currently available communication resources.
In this embodiment of the application, the sending policy may include a sending sequence sent to a plurality of event consumers, or several event callback instructions sent at the same time point.
In step S2055, an event callback instruction is transmitted to the plurality of event consumers based on the transmission policy.
By using the implementation method of the embodiment of the application, the callback function can be effectively called to send the event callback instruction to the event consumer without being blocked.
Fig. 5 is a schematic diagram illustrating an event initiative notification, according to an exemplary embodiment, as shown in fig. 5, including an event consumer, an event provider and an event center system, the entire event initiative notification may be summarized in four steps, including:
the first step is as follows: the event provider registers events through an event center system;
the second step is that: event consumer monitors event through event center system;
the third step: event providing direction informs the event center system of event triggering;
the fourth step: the event center system provides event callbacks to event consumers.
In the prior art, regarding the communication method between the event provider and the event consumer, for example, the communication method between the localization application and the H5 page may mainly include the following three methods:
mode 1, window object through front window is used as relay. Wherein the window is opened in the window object browser. By default, if the document contains frames (frame or iframe tags), the browser will create a window object for the H5 page and an additional window object for each frame, and all browsers will support the object. The specified interface is the Bridge, i.e., Bridge (Bridge), for communication between the localization application and the H5 page.
Mode 2, scheme protocol mode based on iframe request. The communication protocol between the localization application and the H5 page is a communication protocol agreed by a hybrid scheme, and the localization application and the H5 page can communicate according to the agreement.
Mode 3, a mode of injecting the custom transit object and the method by means of a JavaScriptCore/V8 engine. JavaScriptCore is an open source framework that provides a JS engine in WebKit, which is currently maintained by Apple, and is integrated into the iPhone platform after being used in Safari browser, iOS 7. V8 is a high-performance open source JS engine developed and maintained by Google, written in C + +, used in the Google Chrome browser. Like JavaScriptCore, in Android development, the relevant interfaces need to be called through a layer of wrapper. The open source project J2V8 on Github implements encapsulation of V8 by Java based on jni. JavaScript is the main language of HTML5 and Native interaction, JavaScript objects and Native language objects can be bound by means of JavaScript core and J2V8 provided by a platform system, and two sides of a method provided by the objects can be shared, so that communication is realized. Currently this approach is the mainstream communication approach. The method here is also a Bridge for implementing two communications, which is called Bridge (Bridge), as in the method of the same manner, and is different from method 1 in that method 1 forwards calls of various functions through a common Bridge, and in this manner, each function corresponds to a method in which JavaScript objects are shared on both sides.
Through the analysis to the scheme in 3 above-mentioned, can obtain public vulnerability: since each event corresponds to a bridge, which belongs to the calling of a single channel, each time the event consumer needs to determine whether an event occurs, the event consumer needs to call the bridge corresponding to the event to poll the event provider to determine whether the event occurs.
By the method provided by the embodiment of the application, when any target event occurs at the event provider, the event center system can be informed actively through the event trigger instruction, and then the event consumer monitoring the target event is informed, so that the event provider is ensured to inform actively, and meanwhile, the informing efficiency is improved.
Secondly, event registration, event monitoring and event triggering are performed between the event provider and the event center system or between the event consumer and the event center system through a unified interface, so that the problem that in the prior art, the event consumer needs to call a corresponding interface or bridge to acquire a structure in a polling mode to acquire whether a certain target event occurs in the event provider can be avoided, and the purposes of saving time and interface resources are achieved.
Moreover, the event center system effectively manages and plans the sending and receiving of the instructions corresponding to the event provider and the event consumer, and the calling success rate and stability are improved.
Finally, as long as the event provider detects that the target event is triggered, the event provider can send an event trigger instruction to the event center system, so that the event center system sends an event callback instruction to the event consumer, therefore, the event provider can realize multiple event trigger operations and event callback operations as long as one event registration operation and one event monitoring operation are carried out, and the method is simple and convenient.
FIG. 6 is a block diagram illustrating an event notification apparatus according to an example embodiment. Referring to fig. 6, the apparatus includes an instruction receiving module 601, a consumer determination module 602, and an instruction transmitting module 603.
An instruction receiving module 601 configured to execute receiving an event trigger instruction sent by an event provider; the event trigger instruction comprises an event identifier of a target event; the event trigger instruction represents that a target event is triggered and generated at an event provider;
a consumer determination module 602 configured to perform determining an event consumer listening to the target event based on the event identification;
an instruction sending module 603 configured to perform sending an event callback instruction to an event consumer; the event callback instruction comprises an event identifier; the event callback instruction is used for notifying an event consumer that a target event is triggered to be generated at an event provider.
In some possible embodiments, when the event provider comprises a first event provider and a second event provider, the instruction receiving module is configured to perform:
receiving a first event trigger instruction sent by a first event provider through a first interface; the first event trigger instruction comprises an event identification of a first target event;
receiving a second event trigger instruction sent by a second event provider through a first interface; the second event trigger instruction comprises an event identification of the second target event.
In some of the possible embodiments of the present invention,
the instruction receiving module is configured to execute an event registration instruction sent by the event provider; the event registration instruction comprises an event identifier and event description information of the target event; receiving an event monitoring instruction sent by an event consumer; the event monitoring instruction comprises description information of an event to be monitored;
and the consumer determining module is configured to execute the step of determining that the event consumer is the event consumer for monitoring the target event if the description information of the event to be monitored is matched with the event description information of the target event.
In some possible embodiments, the consumer determination module is configured to perform:
determining an event consumer as an event consumer for monitoring a target event;
and establishing a mapping relation between the event identifier of the target event and the event consumer.
In some possible embodiments, the instruction receiving module is configured to perform: receiving a first event registration instruction sent by a first event provider through a second interface; the first event registration instruction comprises an event identification and first event description information of a first target event;
receiving a second event registration instruction sent by a second event provider through a second interface; the second event registration instruction includes an event identification of the second target event and second event description information.
In some possible embodiments, the event listening instruction further comprises a callback function of the event consumer;
the device still includes:
a function saving module configured to execute a callback function of a save event consumer;
an instruction sending module configured to perform:
and sending an event callback instruction to the event consumer based on the callback function of the event consumer.
In some possible embodiments, when the event consumer of the target event is a plurality of event consumers, the instruction sending module is configured to perform:
determining currently available communication resources;
determining a sending strategy of event callback instructions of a plurality of event consumers based on the currently available communication resources;
and sending an event callback instruction to a plurality of event consumers based on the sending strategy.
In some possible embodiments, the event provider and the event consumer are located in the same application program, the event notification device is applied to an event center system, and the event center system is carried by the event provider or the event consumer;
the application program is hybrid App.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 7 is a block diagram illustrating an apparatus 700 for event notification according to an example embodiment. For example, the apparatus 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 7, apparatus 700 may include one or more of the following components: a processing component 702, a memory 704, a power component 706, a multimedia component 708, an audio component 710, an input/output (I/O) interface 712, a sensor component 714, and a communication component 716.
The processing component 702 generally controls overall operation of the device 700, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 702 may include one or more processors 720 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 702 may include one or more modules that facilitate interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate interaction between the multimedia component 708 and the processing component 702.
The memory 704 is configured to store various types of data to support operation at the device 700. Examples of such data include instructions for any application or method operating on device 700, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 704 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 706 provides power to the various components of the device 700. The power components 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 700.
The multimedia component 708 includes a screen that provides an output interface between the device 700 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 700 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 710 is configured to output and/or input audio signals. For example, audio component 710 includes a Microphone (MIC) configured to receive external audio signals when apparatus 700 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 704 or transmitted via the communication component 716. In some embodiments, audio component 710 also includes a speaker for outputting audio signals.
The I/O interface 712 provides an interface between the processing component 702 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 714 includes one or more sensors for providing status assessment of various aspects of the apparatus 700. For example, sensor assembly 714 may detect an open/closed state of device 700, the relative positioning of components, such as a display and keypad of apparatus 700, sensor assembly 714 may also detect a change in position of apparatus 700 or a component of apparatus 700, the presence or absence of user contact with apparatus 700, orientation or acceleration/deceleration of apparatus 700, and a change in temperature of apparatus 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 716 is configured to facilitate wired or wireless communication between the apparatus 700 and other devices. The apparatus 700 may access a wireless network based on a communication standard, such as WiFi, an operator network (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 700 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a storage medium comprising instructions, such as the memory 704 comprising instructions, executable by the processor 720 of the apparatus 700 to perform the method described above is also provided. Alternatively, the storage medium may be a non-transitory computer readable storage medium, which may be, for example, a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.

Claims (10)

1. An event notification method, comprising:
receiving an event trigger instruction sent by an event provider; the event trigger instruction comprises an event identifier of a target event; the event trigger instruction represents that the target event is triggered to be generated at the event provider;
determining an event consumer listening to the target event based on the event identification;
sending an event callback instruction to the event consumer; the event callback instruction comprises the event identifier; the event callback instruction is used for notifying the event consumer that the target event is triggered and generated at the event provider.
2. The event notification method according to claim 1, wherein, when the event providers include a first event provider and a second event provider, the receiving the event trigger instruction transmitted by the event provider includes:
receiving a first event trigger instruction sent by the first event provider through a first interface; the first event trigger instruction comprises an event identification of a first target event;
receiving a second event trigger instruction sent by the second event provider through the first interface; the second event trigger instruction comprises an event identification of a second target event.
3. The event notification method according to claim 2, wherein before receiving the event trigger instruction sent by the event provider, the method further comprises:
receiving an event registration instruction sent by the event provider; the event registration instruction comprises event identification and event description information of the target event;
receiving an event monitoring instruction sent by the event consumer; the event monitoring instruction comprises description information of an event to be monitored;
and if the description information of the event to be monitored is matched with the event description information of the target event, determining that the event consumer is the event consumer monitoring the target event.
4. The event notification method of claim 3, wherein said determining that said event consumer is one of the event consumers listening to said target event comprises:
and establishing a mapping relation between the event identifier of the target event and the event consumer.
5. The event notification method according to claim 3, wherein said receiving the event registration instruction transmitted by the event provider comprises:
receiving a first event registration instruction sent by the first event provider through a second interface; the first event registration instruction comprises an event identification and first event description information of the first target event;
receiving a second event registration instruction sent by the second event provider through the second interface; the second event registration instruction includes an event identifier of the second target event and second event description information.
6. The event notification method according to claim 3, wherein said event listening instruction further comprises a callback function of said event consumer;
the sending of the event callback instruction to the event consumer comprises:
and sending the event callback instruction to the event consumer based on the callback function of the event consumer.
7. An event notification apparatus, comprising:
the instruction receiving module is configured to execute an event triggering instruction sent by the event providing party; the event trigger instruction comprises an event identifier of a target event; the event trigger instruction represents that the target event is triggered to be generated at the event provider;
a consumer determination module configured to perform determining event consumers listening to the target event based on the event identification;
an instruction sending module configured to perform sending an event callback instruction to the event consumer; the event callback instruction comprises the event identifier; the event callback instruction is used for notifying the event consumer that the target event is triggered and generated at the event provider.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the event notification method of any of claims 1 to 6.
9. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the event notification method of any of claims 1-6.
10. A computer program product, characterized in that the computer program product comprises a computer program stored in a readable storage medium, from which at least one processor of a computer device reads and executes the computer program, causing the computer device to perform the event notification method according to any one of claims 1 to 6.
CN202111155112.0A 2021-09-29 2021-09-29 Event notification method and device, electronic equipment and storage medium Pending CN114048042A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111155112.0A CN114048042A (en) 2021-09-29 2021-09-29 Event notification method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111155112.0A CN114048042A (en) 2021-09-29 2021-09-29 Event notification method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114048042A true CN114048042A (en) 2022-02-15

Family

ID=80204785

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111155112.0A Pending CN114048042A (en) 2021-09-29 2021-09-29 Event notification method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114048042A (en)

Similar Documents

Publication Publication Date Title
CN108833585B (en) Information interaction method and device and storage medium
CN108702763B (en) Method and device for sending lead code and scheduling request
CN105808305B (en) Static resource loading method and device
CN107094094B (en) Application networking method and device and terminal
CN108965413B (en) Information interaction method and device and storage medium
CN109525652B (en) Information sharing method, device, equipment and storage medium
CN113420338B (en) Data processing method and device for data processing
CN113783774A (en) Cross-cluster network configuration method and device, communication equipment and storage medium
CN110704030A (en) Interface configuration information generation method and device, electronic equipment and storage medium
CN111314419B (en) Network request method and device
CN110337825B (en) Service switching method and device
CN106412481B (en) Reminding method, device and terminal based on VoLTE video calling
CN113238881B (en) Page communication method and device
CN104572230B (en) Script file loading method and device and script file generating method and device
CN114430410B (en) System access method, device and equipment based on virtual domain name
CN114048042A (en) Event notification method and device, electronic equipment and storage medium
JP6311028B2 (en) Telephone interaction method, user terminal, telephone agent system, telephone interaction system, program, and recording medium
CN105554141A (en) Resource management and control method and device of intelligent device
CN114385373A (en) Data sharing method, data sharing device and computer readable storage medium
CN112035246A (en) Method, device and system for acquiring virtual resources, electronic equipment and storage medium
CN111049732A (en) Push message display method and device, electronic equipment and medium
CN115203618B (en) Page processing method and device, electronic equipment and storage medium
CN114531493B (en) Request processing method and device, electronic equipment and storage medium
CN112449409B (en) Power control method of mobile terminal and power control device of mobile terminal
CN112764885B (en) Object access method, device, electronic equipment, storage medium and program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination