An event processing method, device, electronic device and storage medium

By introducing proxy objects and globally unique event identifiers to the game engine event system, the code coupling problem caused by combined events is solved, and the game development needs of high cohesion and low coupling are achieved, and the development efficiency is improved.

CN115774625BActive Publication Date: 2025-07-04NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211484023.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-24
Publication Date
2025-07-04
Estimated Expiration
2042-11-24

AI Technical Summary

Technical Problem

When the existing game engine event system handles complex combined events, the code coupling between the event publishing object and the subscription object is severe, and it cannot meet the requirements of high cohesion and low coupling, resulting in inefficient game development.

Method used

By assigning a proxy object to record the event trigger status identification for each event group, and using globally unique event identification to realize the interaction between the event system and the proxy object, the triggering of combined events is completed, and subscriptions and callbacks of combined events are supported, and the same piece of code logic is reused.

Benefits of technology

It realizes high cohesion and low coupling of different event groups, improves game development efficiency, and maintains the simplicity and scalability of the code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115774625B_ABST
    Figure CN115774625B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer technologies, and particularly to an event processing method, apparatus, electronic device, and storage medium. After receiving a subscription request for a target combined event in a target event group sent by a first subscription object, the present application determines whether there is a target proxy object for recording an event trigger status identifier of the target event group; if there is, it determines whether to trigger the target combined event based on the current event trigger status identifier and the event identifier of the target combined event; after triggering the target combined event, a notification message indicating that the triggering of the target combined event is completed is sent to the first subscription object through a first callback function. In this way, the present application realizes the interaction between the event system and the proxy object through a globally unique event identifier to complete the triggering of combined events, enabling different event groups to reuse the same piece of code logic, meeting the requirements of high cohesion and low coupling, and thus improving the game development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technologies, and in particular, to an event processing method, apparatus, electronic device, and storage medium. Background Art

[0002] In game development, the use of events is very common, such as event subscription, event triggering, and event callback. The most basic events include screen click events, keyboard click events, touch button events, etc. Generally, the encapsulated event system provided by the game engine can handle the events corresponding to the above basic requirements.

[0003] However, as the game logic becomes more complex, there will be more complex combined event requirements. For example, the client needs to know the event that the scene loading is completed, and the scene loading completion includes two preconditions: the map loading is completed and the protagonist model loading is completed. These two are executed in parallel. It is possible that the map is loaded first, or it is possible that the protagonist is loaded first, but the client only cares about the moment when both are loaded. When facing combined event requirements like this, there will be a large amount of coupling between the code of the event publishing object and the event subscribing object in the game. Therefore, for the requirements of combined events, the event system in this design method cannot meet the requirements of keeping the project code with low coupling and high cohesion, resulting in low game development efficiency. Summary of the Invention

[0004] In view of this, at least one event processing method, apparatus, electronic device, and storage medium are provided in the embodiments of this application, which can meet the requirements of high cohesion and low coupling, thereby improving game development efficiency.

[0005] This application mainly includes the following aspects:

[0006] In a first aspect, an event processing method is provided in an embodiment of this application. The event processing method includes: receiving a subscription request sent by a first subscription object for a target combined event in a target event group; the subscription request carries an event identifier of the target combined event and a first callback function; determining whether there is a target proxy object for recording an event trigger status identifier of the target event group; if so, based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combined event, determining whether to trigger the target combined event; the current event trigger status identifier is obtained according to a historical event trigger status identifier and the event identifier of at least one event in the currently triggered target event group; if so, after triggering the target combined event, sending a notification message indicating that the triggering of the target combined event is completed to the first subscription object through the first callback function.

[0007] Second aspect, an embodiment of the present application further provides an event processing device, where the event processing device includes: a receiving module, configured to receive a subscription request for a target combined event in a target event group sent by a first subscription object; the subscription request carries an event identifier of the target combined event and a first callback function; a judgment module, configured to judge whether there is a target proxy object for recording an event trigger status identifier of the target event group; a determination module, configured to, if the target proxy object exists, determine whether to trigger the target combined event based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combined event; the current event trigger status identifier is obtained according to a historical event trigger status identifier and an event identifier of at least one event in the currently triggered target event group; a first sending module, configured to, if it is determined that the target combined event is triggered, after triggering the target combined event, send a notification message indicating that the triggering of the target combined event is completed to the first subscription object through the first callback function.

[0008] Third aspect, an embodiment of the present application further provides an electronic device, including: a processor, a memory, and a bus, where the memory stores machine-readable instructions executable by the processor, and when the electronic device runs, the processor communicates with the memory through the bus, and when the machine-readable instructions are run by the processor, the steps of the event processing method described in the first aspect above are executed.

[0009] Fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the steps of the event processing method described in the first aspect above are executed.

[0010] The event processing method, device, electronic device, and storage medium provided by the embodiments of the present application complete the triggering of combined events by allocating a proxy object for recording the event trigger status identifier for each event group and enabling the interaction between the proxy object and the event system through a globally unique event identifier. Compared with the prior art, when facing similar combined event requirements, there will be a large amount of coupling between the event publishing object and the event subscription object in the game, resulting in low game development efficiency. The present application can enable different event groups to reuse the same code logic to meet the requirements of high cohesion and low coupling, thereby improving the game development efficiency.

[0011] Furthermore, for the event processing method provided by the embodiments of the present application, after receiving a trigger message for any sub-event in the target event group sent by the target publishing object, the callback function mapping table can be traversed to determine a second callback function and a third subscribing object associated with the event identifier of the sub-event; and a notification message indicating that the sub-event has been triggered is sent to the third subscribing object through the second callback function. In this way, the subscription of combined events is supported on top of the common event system based on single-event subscription. This not only does not affect the use of the original simple single event, but also enables the sub-events or combined events under the event group to be triggered and subscribed to as single events.

[0012] To make the above objects, features, and advantages of the present application more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, provides a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] To more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative efforts.

[0014] Figure 1 FIG. shows a schematic diagram of an event processing architecture provided by an embodiment of the present application;

[0015] Figure 2 FIG. shows a flowchart of an event processing method provided by an embodiment of the present application;

[0016] Figure 3 FIG. shows a flowchart of another event processing method provided by an embodiment of the present application;

[0017] Figure 4 FIG. shows a functional module diagram of an event processing device provided by an embodiment of the present application;

[0018] Figure 5 FIG. shows a functional module diagram of an event processing device provided by an embodiment of the present application;

[0019] Figure 6 FIG. shows a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. It should be understood that the accompanying drawings in this application are only for the purpose of illustration and description, and are not used to limit the protection scope of this application. Additionally, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate the operations implemented according to some embodiments of this application. It should be understood that the operations in the flowchart may not be implemented in sequence, and steps without a logical context relationship may be reversed or implemented simultaneously. Furthermore, those skilled in the art can add one or more other operations to the flowchart or remove one or more operations from the flowchart under the guidance of the content of this application.

[0021] In addition, the described embodiments are only some embodiments of this application, rather than all of the embodiments. The components of the embodiments of this application generally described and illustrated in the accompanying drawings here can 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 this application that is claimed, but merely represents the selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative efforts fall within the protection scope of this application.

[0022] To enable those skilled in the art to use the content of this application, the following implementation manners are given in combination with the specific application scenario of "event handling". For those skilled in the art, without departing from the spirit and scope of this application, the general principles defined here can be applied to other embodiments and application scenarios.

[0023] The following methods, devices, electronic devices, or computer-readable storage media in the embodiments of this application can be applied to any scenario that requires event handling. The embodiments of this application do not limit the specific application scenario, and any solution that uses the event handling methods and devices provided in the embodiments of this application falls within the protection scope of this application.

[0024] It is worth noting that before this application was proposed, the packaged event system provided by the game engine could only handle simple and single events such as screen click events, keyboard click events, and touch button events. When facing requirements for combined events like this, there would be a large amount of coupling between the code of the event publishing object and the event subscribing object in the game. Therefore, for the requirements of combined events, the event system in this design method cannot meet the requirements of keeping the project code low-coupled and highly cohesive, resulting in low game development efficiency.

[0025] To address the above problems, the present application realizes the interaction between the event system and the proxy object through a globally unique event identifier to complete the triggering of combined events, enabling different event groups to reuse the same code logic, meeting the requirements of high cohesion and low coupling, and thus improving the game development efficiency.

[0026] It should be noted that, generally, the event system is an essential module in game development. The event system can implement the commonly used functions involved in interactions during game development. Using the event system can not only send input behaviors (such as keyboard, mouse, touch) to the application in the form of events, but also respond to things that occur during the game and require the attention of other objects in the form of events.

[0027] It should also be noted that high cohesion and low coupling are concepts in software engineering. High cohesion and low coupling are criteria for judging the quality of software design, mainly used in the object-oriented design of programs, mainly looking at whether the cohesion of classes is high and the coupling degree is low. The purpose is to greatly enhance the reusability and portability of program modules. Usually, the higher the cohesion degree of each module in the program structure, the lower the coupling degree between modules. Cohesion measures the connection within a module from a functional perspective. A good cohesive module should do exactly one thing, which describes the functional connection within the module; coupling is a measure of the mutual connection between modules in the software structure, and the strength of coupling depends on the complexity of the module interface, the point of entry or access to a module, and the data passing through the interface.

[0028] In addition, the "event subscription object" in the present application can be interchanged with the "event subscriber" and the "event listener"; the "event publishing object" in the present application can be interchanged with the "event publisher" and the "event trigger".

[0029] To facilitate the understanding of the present application, the technical solutions provided by the present application will be described in detail below in conjunction with specific embodiments.

[0030] Figure 1The figure shows a schematic diagram of an event processing architecture provided by an embodiment of the present application. The event processing architecture includes an event system 110 (event processing device), at least one publishing object 120, at least one subscribing object 130, and at least one proxy object 140; wherein, one proxy object 140 is configured for each event group, and this proxy object is used to record the event trigger status identifier of the corresponding event group. Here, by enabling the event system 110 to interact with the publishing object 120, subscribing object 130, and proxy object 140 respectively, and preventing the publishing object 120, subscribing object 130, and proxy object 140 from interacting with each other, different event processing can be achieved, such as event triggering, event subscription, and event callback. In this way, the code coupling between the subscribing object 130 and the publishing object 120 can be effectively avoided, and the overall code can be kept concise by only connecting through the event system 110.

[0031] Specifically, for a simple single sub-event, after a certain subscribing object 130 sends a subscription request to the event system 110 for any sub-event in a certain event group, if a certain publishing object 120 triggers this sub-event, the event publisher will send this trigger message to the event system 110. After the event system 110 receives this trigger message, on the one hand, the event system 110 will notify this trigger message to the subscribing object 130 that has subscribed to this sub-event, so that this subscribing object 130 knows that the sub-event it has subscribed to has been triggered; on the other hand, the event system 110 will send this trigger message to the proxy object 140 that is used to record the event trigger status identifier of this event group, so that this proxy object updates the event trigger status identifier of this event group. In this way, the subscription, triggering, and callback of a single sub-event are completed, and the recording of the event trigger status identifier of this event group is completed.

[0032] For a combined event, after a certain subscribing object 130 sends a subscription request to the event system 110 for a combined event in a certain event group, if a certain proxy object 140 detects that the current event trigger status identifier of this event group recorded by itself is consistent with the event identifier of this combined event, this proxy object 140 determines that this combined event meets the trigger condition, and then this proxy object 140 will send a notification message indicating that this combined event meets the trigger condition to the event system 110. In this way, the event system 110 triggers this combined event. After the event system 110 triggers this combined event, it sends a notification message indicating that this combined event has been triggered to the subscribing object 130 that has subscribed to this combined event through a callback function. In this way, the subscription, triggering, and callback of the combined event are completed.

[0033] Figure 2 The figure shows a flowchart of an event processing method provided by an embodiment of the present application; the event processing method is applied to an event system, and the event processing method includes the following steps:

[0034] S201: Receive a subscription request for a target combined event in a target event group sent by a first subscription object.

[0035] Wherein, the event identifier of the target combined event and a first callback function are carried in the subscription request.

[0036] In a specific implementation, the event system can receive a subscription request for a combined event sent by any one subscription object. This subscription request can be understood as a request for the subscription object to know the message corresponding to the triggering of this combined event. The callback function carried in this subscription request is a function used to notify the subscription object of this triggering message.

[0037] Here, there is a callback function mapping table in the event system. At least one list of callback functions associated with event identifiers is stored in this callback function mapping table. At least one callback function associated with this event identifier is stored in this list of callback functions. The identity information of the subscription object is carried in this callback function. Generally, each subscription object corresponds to at least one callback function.

[0038] It should be noted that there is at least one event group in the event processing architecture provided by the embodiments of the present application. Each event group includes at least one sub-event. In an event group with two sub-events, at least one combined event can also be included. Each event group corresponds to a group identifier. The event identifier of any sub-event in each event group includes the group identifier of this event group and the sub-identifier of this sub-event. If a combined event in an event group has an association relationship with a first sub-event and a second sub-event in this event group, then the event identifier of this combined event is determined based on the event identifier of this first sub-event and the event identifier of this second sub-event. In this way, the globally unique event identifier of the combined event can be obtained through the event identifiers of at least two sub-events, without the need to separately define the event identifier of the combined event, greatly reducing the definition cost. Here, the event identifier of any event can be a digital identifier, as long as it satisfies that the event identifier of any event has the property of a bit mask and is a globally unique identifier in the event processing architecture.

[0039] In an example, an event group includes a first sub-event, a second sub-event, and a combined event. The first sub-event is a "map loading event", the second sub-event is a "main character model loading event", and the combined event is a "scene loading event". In one case, it may be that only after both the first sub-event and the second sub-event are triggered, can this combined event be triggered.

[0040] S202: Determine whether there is a target proxy object for recording the event trigger status identifier of the target event group.

[0041] In a specific implementation, the event system creates a proxy object for each event group. Each proxy object is used to record the event trigger status flag of the corresponding event group, and this event trigger status flag can represent the current trigger situation of each event (including sub-events and combined events) in this event group.

[0042] Here, the initial event trigger status flag of an event group is obtained based on the group identifier of this event group. As each event in this event group is triggered separately, this event trigger status flag is continuously updated. Each updated event trigger status flag (the current event trigger status flag) is obtained based on the historical event trigger status flag and the event identifiers of at least one event in the currently triggered event group.

[0043] In an example, the initial event trigger status flag of an event group recorded by a proxy object is 00010000. At a certain moment, the first sub-event in this event group is triggered, and this event trigger status flag is updated to 00010001; at a certain moment, the second sub-event in this event group is triggered again, and this event trigger status flag is updated to 00010011.

[0044] S203: If it exists, based on the current event trigger status flag of the target event group recorded by the target proxy object and the event identifier of the target combined event, determine whether to trigger the target combined event.

[0045] Among them, the current event trigger status flag is obtained based on the historical event trigger status flag and the event identifiers of at least one event in the currently triggered target event group.

[0046] In a specific implementation, it is possible to determine whether the trigger condition of the target combined event is met according to the comparison result of the current event trigger status flag of the target event group recorded by the target proxy object and the event identifier of the target combined event. If it is met, the event system directly triggers the target combined event.

[0047] It should be noted that if a subscription request for subscribing to this combined event is sent by a subscription object just after a combined event is triggered, this combined event will not be triggered again. Instead, the event system directly notifies the subscription object of the notification message that this combined event has been triggered through the callback function of this subscription object.

[0048] Here, two implementation schemes for determining whether to trigger a target combination event are given. Scheme 1: The event system compares the current event trigger status identifier of the target combination event with the event identifier of the target combination event. Specifically, determining whether to trigger the target combination event based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combination event in step S203 includes the following steps: obtaining the current event trigger status identifier of the target event group recorded by the target proxy object; determining whether the current event trigger status identifier is consistent with the event identifier of the target combination event; if they are consistent, it is determined to trigger the target combination event.

[0049] Scheme 2: The target proxy object compares the current event trigger status identifier of the target combination event with the event identifier of the target combination event, and the target proxy object sends a message with a consistent comparison result to the event system, and the event system triggers the target combination event. Specifically, determining whether to trigger the target combination event based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combination event in step S203 includes the following steps: receiving the notification information sent by the target proxy object indicating that the target combination event meets the trigger condition; the target proxy object determines that the trigger condition is met based on the consistency between the current event trigger status identifier and the event identifier of the target combination event; it is determined to trigger the target combination event.

[0050] In an example, an event group includes a first sub-event, a second sub-event, and a combination event. The event logic is that after both the first sub-event and the second sub-event are triggered, it is determined that the combination event meets the trigger condition. Here, the event identifier of any event in the event group is represented in binary form of numbers. Specifically, the group identifier of the event group is 0001, the event identifier of the event group is 00010000, the event identifier of the first sub-event is 00010001, and the event identifier of the second sub-event is 00010010. Among them, the first four bits of the event identifier of any sub-event are the group identifier, and the last four bits are the sub-identifier; the event identifier of the combination event = the logical OR operation result of the event identifier of the first sub-event and the event identifier of the second sub-event = 00010001 | 00010010 = 00010011.

[0051] In addition, the initial event trigger status of this event group recorded by the proxy object of this event group is marked as 0001000 (which is the event identifier of this event group). At a certain moment, the first sub-event in this event group is triggered, and the event trigger status identifier = 00010000|00010001 = 00010001; at a certain moment, the second sub-event in this event group is triggered again, and the event trigger status identifier = 00010001|00010010 = 00010011 (the current event trigger status identifier). When actually determining whether this combined event meets the trigger condition, it can be determined whether the current event trigger status identifier of this event group is consistent with the event identifier of this combined event. At this time, if the two are consistent, the event system can trigger this target combined event.

[0052] S204: If so, after triggering the target combined event, send a notification message indicating that the target combined event has been triggered to the first subscription object through the first callback function.

[0053] In a specific implementation, if it is determined that the target combined event can be triggered, after the event system triggers the target combined event, it looks up in the callback function mapping table to check if there is a callback function associated with the event identifier of the target combined event. This can also be understood as a process of finding the subscription object that subscribes to the target combined event. For example, if the first callback function is found, it is determined that the first subscription object that sends the first callback function subscribes to the trigger event of the target combined event, and then a notification message indicating that the target combined event has been triggered is sent to the first subscription object through the first callback function. Here, there can be one or more subscription objects subscribing to the same event, and the subscribed event can be a combined event or a sub-event. In addition, if there are other subscription objects that also subscribe to this event, the notification message will also be sent to these other subscription objects.

[0054] In addition, any subscription object can also cancel the event that was previously subscribed to in the event system. When the event system receives a subscription cancellation request sent by a subscription object for a certain event, it can directly clear the callback function corresponding to this subscription object in the callback function mapping table.

[0055] It should be noted that for the triggering, subscription, and callback of events, the inventor has thought of some basic implementation solutions. Here, only the two solutions that are closest to this application are described: Solution a - ID-based event system; Solution b - Bitmask-based combined event system.

[0056] For a simple and single event, the workflow of Solution A is roughly as follows: (1) Define an event ID; (2) The event subscription object registers a callback function with the event system; (3) The event system internally maintains a mapping table of event IDs and callback functions; (4) Each module obtains an instance of the event system through the event system to trigger an event; among them, the module can be an event publishing object; (5) The event system traverses the internally maintained mapping table and sequentially calls the callback functions, passing through the event subscription object.

[0057] Here, in Solution A, the event ID can also directly use the event name string, which is more intuitive. However, the disadvantage is that this design cannot meet the triggering of complex combined events. For example, when the scene loading is completed, it needs to be triggered after the map loading is completed and the protagonist model loading is completed, and these two independent sub-events are triggered separately. Using this type of event system, three event IDs need to be defined, and an additional piece of logic for listening to the two sub-events needs to be written. Therefore, the development cost of adopting Solution A is relatively high, which cannot meet the requirements of low coupling and high cohesion of the code, resulting in a relatively low game development efficiency.

[0058] For combined events, the workflow of Solution A is roughly as follows: (1) Define a sub-event A, which has a globally unique event ID. (2) Define a sub-event B, which has a globally unique event ID. (3) Define a combined event AB, which has a globally unique event ID. (4) Module M subscribes to the combined event AB. (5) Module N subscribes to sub-event A. (6) Module N subscribes to sub-event B. (7) At a certain moment, a certain module triggers sub-event A, and the event system calls back to inform Module N. Module N records that sub-event A has been triggered and executes (9). (8) At a certain moment, a certain module triggers sub-event B, and the event system calls back to inform Module N. Module N records that sub-event B has been triggered and executes (9). (9) Module N determines whether both sub-event A and sub-event B have been triggered. If both have been triggered, then trigger the combined event AB. (10) The event system triggers the combined event AB and calls the callback function to inform Module M. Here, in this way, a dedicated module needs to be added to handle the combined event triggering method, that is, a new module needs to be written to handle it, which increases the scattered modules and reduces the cohesion degree.

[0059] As can be clearly seen from the above steps, steps (5) to (9) above may be executed by a certain new module N, or may be executed internally within module M itself. The disadvantage of this is that for each new combined event, a new set of steps (5) to (9) needs to be written, which will inevitably increase the development cost significantly. Based on this, the inventor thought of a way to improve solution a to achieve the reuse of the code logic in steps (5) to (9) above. For example, steps (5) to (9) can be integrated into the event system to achieve reuse, and the triggering of combined events can be used as a function of the event system, rather than being processed separately by each module. This only adds the function of the event system and also reduces the number of modules (when steps (5) to (9) are executed by a certain new module N) or the complexity of the remaining modules (when executed internally within module M itself), which conforms to the idea of high cohesion and low coupling.

[0060] For simple and single events, the working process of solution b is roughly as follows: (1) Define an event group containing multiple sub-events; (2) Use a binary number with the same number of digits as the number of sub-events to represent the state of the event group. If the corresponding digit of a sub-event is set to 1, it means the sub-event is triggered, otherwise it is not triggered. For example,

[000] means none of A, B, and C are triggered,

[010] means event B is triggered, and

[011] means events B and C are triggered; (3) Each time a sub-event is triggered, set the corresponding flag bit to 1 and determine whether the overall state of the current event group requires the triggering of a combined event.

[0061] Here, the inventor found that the bit-mask-based design of solution b can more intuitively meet the function of triggering combined events, but there will be some defects when facing multiple different event groups.

[0062] Specifically, for combined events, the working process of solution b is roughly as follows: (1) Define an event group containing multiple sub-events, and use an integer number with the same number of digits as the number of sub-events to mark the triggering state of the current event group. (2) Assume that event group E contains three sub-events A, B, and C, and each bit represents the state of a sub-event, 0 means not triggered, and 1 means triggered. For example, the triggering state 000 means no event is triggered, 001 means only sub-event A is triggered, 010 means only sub-event B is triggered, and 100 means only sub-event C is triggered. (3) Each time a sub-event is triggered, set the corresponding flag bit of the triggering state to 1 and determine the overall state of the current event group. (4) If the triggering state is 011, it means both A and B are triggered, and trigger the execution of the logic corresponding to combined event AB; if the triggering state is 101, it means both A and C are triggered, and trigger the execution of the logic corresponding to combined event AC; if the triggering state is 110, it means both B and C are triggered, and trigger the execution of the logic corresponding to combined event BC; if the triggering state is 111, it means A, B, and C are all triggered, and trigger the execution of the logic corresponding to combined event ABC.

[0063] It is clear from the above steps that logically speaking, the functions implemented by the above solution b are consistent with the functions implemented by steps (5) to (9) in solution a, but there is no concept of global event ID. The advantage is that this bit mask-based method is more intuitive, and three bits can represent all eight combined event states; while steps (5) to (9) require a new globally unique event ID to be declared for each combined event, which is more cumbersome. Based on this, the inventors thought about how to encapsulate the code so that event groups with different numbers of sub-events can reuse the same code logic, and how to combine combined events with an ID-based event system to ensure the characteristics of high cohesion and low coupling.

[0064] It should be noted that a good event system can also significantly reduce code coupling, so that the project code maintains the principle of low coupling and high cohesion, to improve code readability, facilitate expansion, and improve development efficiency. So far, based on the principle of low coupling and high cohesion, the inventor has also referred to the problems existing in the triggering, subscription and callback processes of the above schemes a and b for combined events, as well as his own targeted thinking, and has thought of how to combine the technical ideas of the global unique ID in scheme a and the technical ideas of the trigger state representation in scheme b, and integrate them into the event system as an event system function, and make it easy to reuse it in event groups with different numbers of sub-events, so as to meet the requirements of high cohesion and low coupling, thereby improving the technical effect of game development efficiency.

[0065] Following this idea, the inventors came up with the idea of ​​combining bit mask-based combined events with an ID-based event system. The key lies in how to ensure that all sub-events under different event groups, as well as all combined events obtained by permutation and combination of sub-events, have globally unique event IDs. Having globally unique event IDs ensures that these sub-events and combined events can be embedded in the ID-based event system for use, and will not affect each other or the triggering of a single event. Furthermore, by making the IDs of all sub-events and combined events under the same event group have the characteristics of a bit mask and can be calculated through bit operations, cumbersome and redundant ID declaration definitions can be avoided, and the same set of code logic can be applied to all event groups. In this way, the technical solution of the present application is formed.

[0066] The implementation process of the technical solution of the embodiment of the present application is to set a globally unique event identifier for each event in the event group, assign a proxy object for each event group to record its event triggering state identifier, and complete the triggering of the combined event through the interaction between the proxy object and the event system. In this way, different event groups can reuse the same code logic, which can meet the requirements of high cohesion and low coupling, thereby improving the efficiency of game development.

[0067] In a possible implementation, after the event system receives a subscription request for any sub-event or combined event sent by any subscription object, it needs to check whether the event identifier of this event exists in the callback function mapping table, and take different handling methods according to the result of whether it exists. If the event identifier exists, it only needs to retrieve the callback function list corresponding to this event identifier, and add the callback function carried in this subscription request to this callback function list; if the event identifier does not exist, it is necessary to create a key-value pair, where the "key" in this key-value pair is the event identifier of this event, and the "value" is the callback function list including this callback function, and store this key-value pair in the callback function mapping table.

[0068] Here, taking the combined event as an example for illustration, the process steps corresponding to the combined event include: after receiving the subscription request for the target combined event sent by the first event subscription object in step S201, querying whether the event identifier of the target combined event exists in the callback function mapping table; if it exists, establishing an association relationship between the first callback function and the event identifier of the target combined event and then storing it in the callback function mapping table; if it does not exist, creating a key-value pair with the event identifier of the target combined event as the key and an empty callback function list as the value, inserting the first callback function at the end of the callback function list, and storing the key-value pair in the callback function mapping table.

[0069] In a possible implementation, generally, the creation of an agent object has a creation timing. It can be that the event system pre-creates an agent object for each event group in the entire event processing architecture respectively; it can also be that the event system creates the agent object of this event group when receiving an initialization request for a certain event group sent by a certain subscription object; it can also be that the event system creates the agent object of this event group when receiving a subscription request from a certain subscription object for a certain event in a certain event group.

[0070] The following separately explains two of these situations. Situation 1: Before receiving the subscription request for the target combined event in the target event group sent by the first subscription object in step S201, receiving the initialization request for the target event group sent by the second subscription object; the initialization request carries the group identifier of the target event group; creating the target agent object; where the initial event trigger status identifier of the target event group recorded by the target agent object is obtained based on the group identifier of the target event group.

[0071] Situation 2: After judging whether there is a target agent object for recording the event trigger status identifier of the target event group in step S202, if not, creating the target agent object.

[0072] Figure 3 The flowchart of another event processing method provided by an embodiment of the present application is shown; the event processing method is applied to an event system, and the event processing method includes the following steps:

[0073] S301: Receive a trigger message sent by a target publishing object for any sub-event in the target event group.

[0074] S302: Send the trigger message to the target proxy object so that the target proxy object updates the event trigger status flag of the target event group.

[0075] Wherein, the event identifier of the sub-event is carried in the trigger message.

[0076] In a specific implementation, after the event system receives a trigger message sent by any publishing object for a certain sub-event, it is necessary to send the trigger message to the proxy object corresponding to the event group to which the sub-event belongs, so that the proxy object updates the event status flag of the event group.

[0077] S303: Traverse the callback function mapping table to determine a second callback function and a third subscription object associated with the event identifier of the sub-event; send a notification message indicating that the triggering of the sub-event is completed to the third subscription object through the second callback function.

[0078] Wherein, the order of step S302 and step S303 can be interchanged or they can be carried out simultaneously.

[0079] It should be noted that each subscription object usually corresponds to at least one callback function, and the subscription events corresponding to different callback functions of the same subscription object will be different. Here, there is no absolute correspondence between the "nth" callback function and the "nth" subscription object, where "nth" is only for distinction.

[0080] In a specific implementation, after the event system receives a trigger message sent by any publishing object for a certain sub-event, it is necessary to determine whether there is a subscription object that subscribes to the sub-event. If so, it is necessary to notify the subscription object of the notification message that the sub-event has been triggered. Specifically, traverse the callback function mapping table to determine whether there is the event identifier of the sub-event. If so, then find the function mapping table associated with the event identifier of the sub-event from the callback function mapping table, and send a notification message indicating that the triggering of the sub-event is completed to each subscription object that subscribes to the sub-event through the callback function in the function mapping table.

[0081] It should be noted that the technical solution of this application can be implemented on the basis of the above-mentioned solution a - the ID-based event system, or a set of event processing architectures can be reconfigured. If you want to implement it on the basis of solution a, you can directly add the function of supporting combined event triggering on the original ID-based event system without affecting the function code related to the original single event triggering, which can avoid large-scale module modification and regression testing.

[0082] In one example, assume that there are already 1000 events in the ID-based event system of the original project, and the event IDs are 1 to 1000. Then the maximum number of sub-events in a single event group macro can be defined as 10. The 10th power of 2 is 1024. The event group ID length macro can be defined arbitrarily. Assume it is 4. Then the event IDs: 00000000000000 to 00001111111111 (binary) can all be regarded as single simple events. The original event IDs in the original project do not need to be changed.

[0083] In this way, the subscription of combined events is supported on the common ID-based subscription event system without affecting the use of the original simple single event system. The sub-events / combined events under the event group can also be subscribed and triggered as single events. It is an event system that satisfies the characteristics of low coupling and high cohesion, improving the development efficiency while maintaining the code readability and scalability.

[0084] In a possible implementation manner, if the triggering of a combined event in an event group is directly related to the triggering of two sub-events in the event group. For example, the combined event needs to be triggered after both the first sub-event and the second sub-event are triggered. Then, when defining the event identifier of the combined event, the event identifier of the combined event can be determined according to the event identifier of the first sub-event and the event identifier of the second sub-event. In this way, the event identifier of the combined event does not need to be defined separately. Along this line of thought, the event identifier of any combined event in an event group can be determined based on the event identifiers of at least two sub-events in the event group, thus solving the problem of defining the event identifiers of multiple separate combined events mentioned in solution a.

[0085] Here, for the case where the event identifier is a numerical identifier, especially when the event identifier is represented in digital binary form, in order to ensure the global uniqueness of the event identifiers of all events in each event group, the event identifier of the combined event of the event group can be defined as the logical OR operation result of the event identifiers of at least two sub-events in the event group. That is, perform a logical OR operation on the event identifier of the first sub-event and the event identifier of the second sub-event to determine the event identifier of the target combined event.

[0086] Next, an example will be given where the event identifier is represented in digital binary form. Below, the definitions of the event identifiers of the event group, each sub-event in the event group, and the combined event will be described, including: ① It is defined that the event identifier has 8 bits, and the maximum number of sub-events in a single event group is 4. ② Since the maximum number of sub-events in a single event group is 4, each bit of the lower 4 bits represents the sub-identifier of a sub-event; A: 0001, B: 0010, C: 0100, D: 1000. ③ It is defined that the group identifier of the event group is 4 digits, and the high 4 bits of Event 1 and the event identifier represent the event group ID. The combination of the high 4 bits and the low 4 bits is the 8-bit event identifier. ④ Suppose the current event group ID is 0001, then the event identifiers of the four sub-events A, B, C, and D under this event group can be defined as: A: 00010001, B: 00010010, C: 00010100, D: 00011000. ⑤ It is defined that the ID of the combined event obtained by combining A, B, C, and D is the result of the OR operation of the event IDs of these four sub-events. The event identifier of the combined event AB: A|B = 00010011; the event identifier of the combined event AC: A|C = 00010101; the event identifier of the combined event ACD: A|C|D = 00011101. ⑥ Particularly, when the event group ID is 0000, that is, 00000000 to 00001111, it can be regarded as the ID of a simple single sub-event. In this way, all sub-events and combined events can obtain a globally unique event ID that conforms to the bitmask property and does not affect a single event.

[0087] In a possible implementation manner, the event system can also respond to an event status clearing request sent by any subscription object for a certain event group, so as to reset the event trigger status identifier of the event group. Here, the reset can also be understood as initialization, that is, reset the event trigger status identifier of the event group to the initial event trigger status identifier. In this way, it can meet the needs of some subscription objects to execute corresponding actions according to the event trigger situation in the event group in a loop. The specific implementation process includes the following steps: receiving an event status clearing request sent by a fourth subscription object for the target event group; the event status clearing request carries the group identifier of the target event group; sending a reset message for the event trigger status identifier of the target combined event to the target proxy object.

[0088] Here, a specific example of the present application will be given to illustrate the implementation process of publishing, triggering, callback, and clearing of sub-events and combined events in the event group in the present application, including the following steps:

[0089] Step (1), define the event ID length macro, assume it is 8 bits. Define the maximum number of sub-events in a single event group macro, assume it is 4.

[0090] Step (2), define the group identifier of event group E1, and the GroupID is 0001.

[0091] Step (3): Define the event identifier of sub-event A under event group E1, with the ID being GroupID << 4 | 1, i.e., 00010001.

[0092] Step (4): Define the event identifier of sub-event B under event group E1, with the ID being GroupID << 4 | 2, i.e., 00010010.

[0093] Step (5): Determine the event identifier of combined event AB under event group E1, with the ID being A | B, i.e., 00010011.

[0094] Step (6): Define the list of combined events [AB...] included in event group E1.

[0095] Step (7): Module M (which can be a subscription object) requests the event system to initialize the combined event group E1 and passes in the group identifier GroupID of event group E1.

[0096] Step (7.1): The event system creates a proxy object corresponding to event group E1;

[0097] Step (7.2): The proxy object uses a variable State to record the event trigger status identifier of event group E1;

[0098] Step (7.3): The proxy object initializes State to GroupID << 4, i.e., 00010000.

[0099] Step (8): Module M subscribes to combined event AB under event group E1, passes in the event identifier ID of AB, and a callback function MF.

[0100] Step (8.1): The event system queries in the internal callback function mapping table whether there is a key-value pair with the ID of AB as the key. If not, execute step (8.2); if so, execute step (8.3);

[0101] Step (8.2): The callback function dictionary creates a new key-value pair, with the key being the ID of AB and the value being an empty list used to store functions.

[0102] Step (8.3): Take out the callback function list corresponding to the ID of AB and insert MF at the end of the callback function list.

[0103] Step (9): At a certain moment, a certain module triggers sub-event A under event group E1, passes in the ID of A to the event system, and execute step (11).

[0104] Step (10): At a certain moment, a certain module triggers a sub-event B under event group E1, and the ID of B is passed to the event system, and step (11) is executed.

[0105] Step (11), the event system follows the normal event triggering process according to the input triggering event ID.

[0106] Step (11.1), take out the callback function dictionary and pass in the callback function list corresponding to the event ID.

[0107] Step (11.2), traverse the callback function list and call the functions in the callback function list in order.

[0108] Step (11.3), shift the incoming event ID right by 4 bits to obtain the group ID of the event group to which it belongs, GroupID=ID>>4.

[0109] Step (11.4), determine whether there is a proxy object corresponding to event group E1 created in step (7). If there is, proceed to step (12), pass in the trigger event ID, and notify the proxy object that sub-event A is triggered.

[0110] Step (12), the proxy object responds based on the incoming trigger event ID.

[0111] Step (12.1), update the current event group trigger state. State = State | ID; Assuming State is the initialization state, ID is the ID of event trigger A, then State = 00010000 | 00010001 = 00010001 (In addition, if it is assumed that State is the state where A has been triggered, that is, 00010001, and the event B is triggered now, then State = 00010001 | 00010010 = 00010011).

[0112] Step (12.2), traverse the combined event list [AB...] under the event group E1 corresponding to the proxy object.

[0113] Step (12.3), determine whether the current State is equal to the ID of the combined event. If the combined event ID is passed in, notify the event system to trigger the corresponding combined event.

[0114] Step (13), assuming that the event system receives a notification request to trigger the combined event AB.

[0115] Step (13.1), take out the callback function list corresponding to the combined event AB in the callback function dictionary.

[0116] Step (13.2), traverse the callback function list, and call the functions in the callback function list in order; if MF is in the list, call MF.

[0117] Step (14), module M learns that the combined event AB is triggered.

[0118] Step (15), at a certain moment, module M notifies the event system to clear event group E1, and passes in the GroupID of event group E1.

[0119] Step (15.1), the event system internally retrieves the proxy object corresponding to event group E1.

[0120] Step (15.2), the proxy object resets the current State to GroupID << 4, that is, 00010000.

[0121] Here, steps (7) to (15) are only related to the input event identification ID. Therefore, for different combined events, only by referring to the event identification ID defined in advance in steps (2) to (6), the code logic of steps (7) to (15) can be reused.

[0122] Based on the same application concept, an event processing device corresponding to the event processing method provided in the above embodiment is further provided in the embodiment of the present application. Since the principle of solving problems by the device in the embodiment of the present application is similar to the event processing method in the above embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0123] As Figures 4 to 5 shown, Figure 4 FIG. is one of the functional module diagrams of an event processing device 400 provided in the embodiment of the present application. Figure 5 FIG. is the second functional module diagram of an event processing device 400 provided in the embodiment of the present application. As Figure 4 shown, the event processing device 400 includes: a receiving module 410, configured to receive a subscription request sent by a first subscription object for a target combined event in a target event group; the subscription request carries an event identification of the target combined event and a first callback function; a judging module 420, configured to judge whether there is a target proxy object for recording an event trigger status identification of the target event group; a determining module 430, configured to, if the target proxy object exists, determine whether to trigger the target combined event based on the current event trigger status identification of the target event group recorded by the target proxy object and the event identification of the target combined event; the current event trigger status identification is obtained according to a historical event trigger status identification and an event identification of at least one event in the currently triggered target event group; a first sending module 440, configured to, if it is determined that the target combined event is triggered, after triggering the target combined event, send a notification message indicating that the triggering of the target combined event is completed to the first subscription object through the first callback function.

[0124] In a possible implementation, as Figure 5 shown, the event processing device 400 further includes a first creation module 450; the first creation module 450 is configured to receive an initialization request sent by a second subscription object for the target event group before the receiving module 410 receives a subscription request sent by a first subscription object for a target combined event in the target event group; the initialization request carries a group identifier of the target event group; and create the target proxy object; wherein, the initial event trigger status identifier of the target event group recorded by the target proxy object is obtained based on the group identifier of the target event group.

[0125] In a possible implementation, as Figure 5 shown, the event processing device 400 further includes a second sending module 460; the second sending module 460 is configured to: receive a trigger message sent by a target publishing object for any sub-event in the target event group; and send the trigger message to the target proxy object so that the target proxy object updates the event trigger status identifier of the target event group; wherein, the trigger message carries an event identifier of the sub-event.

[0126] In a possible implementation, as Figure 5 shown, the second sending module 460 is further configured to: traverse the callback function mapping table, determine a second callback function and a third subscription object associated with the event identifier of the sub-event; and send a notification message indicating that the sub-event has been triggered to the third subscription object through the second callback function.

[0127] In a possible implementation, as Figure 5 shown, the determining module 430 is specifically configured to: obtain the current event trigger status identifier of the target event group recorded by the target proxy object; determine whether the current event trigger status identifier is consistent with the event identifier of the target combined event; if they are consistent, determine that the target combined event is triggered.

[0128] In a possible implementation, as Figure 5 shown, the determining module 430 is specifically configured to: receive a notification message sent by the target proxy object indicating that the target combined event meets the trigger condition; the target proxy object determines that the trigger condition is met based on the consistency between the current event trigger status identifier and the event identifier of the target combined event; and determine that the target combined event is triggered.

[0129] In a possible implementation, as Figure 5As shown, the target event group further includes a first sub-event and a second sub-event; the event processing device 400 further includes a generation module 470; the generation module 470 is configured to generate an event identifier of the target combined event according to the following steps: determining the event identifier of the target combined event based on the event identifier of the first sub-event and the event identifier of the second sub-event; wherein, the event identifier of any sub-event in the target event group includes the group identifier of the target event group and the sub-identifier of the sub-event.

[0130] In a possible implementation manner, as Figure 5 shown, the event identifier is represented in a digital binary form; the generation module 470 is specifically configured to: perform an OR operation on the event identifier of the first sub-event and the event identifier of the second sub-event to determine the event identifier of the target combined event.

[0131] In a possible implementation manner, as Figure 5 shown, the event processing device 400 further includes a second creation module 480; the second creation module 480 is configured to create the target proxy object after the judgment module 420 determines that there is no target proxy object for recording the event trigger status identifier of the target event group.

[0132] In a possible implementation manner, as Figure 5 shown, the event processing device 400 further includes a query module 490; the query module 490 is configured to, after the receiving module 410 receives a subscription request for a target combined event sent by a first event subscription object, query whether there is an event identifier of the target combined event in a callback function mapping table; if it exists, establish an association relationship between the first callback function and the event identifier of the target combined event and store it in the callback function mapping table; if it does not exist, create a key-value pair with the event identifier of the target combined event as the key and a callback function list including the first callback function as the value, and store the key-value pair in the callback function mapping table.

[0133] In a possible implementation manner, as Figure 5 shown, the event processing device 400 further includes a cleaning module 4000; the cleaning module 4000 is configured to: receive an event status cleaning request for the target event group sent by a fourth subscription object; the event status cleaning request carries the group identifier of the target event group; send a reset message for the event trigger status identifier of the target combined event to the target proxy object.

[0134] In an embodiment of the present application, after receiving a subscription request for a target combined event in a target event group sent by a first subscription object, it is determined whether there is a target proxy object for recording an event trigger status identifier of the target event group; if so, it is determined whether to trigger the target combined event based on the current event trigger status identifier and the event identifier of the target combined event; after triggering the target combined event, a notification message indicating that the target combined event has been triggered is sent to the first subscription object through a first callback function. In this way, the present application realizes the interaction between the event system and the proxy object through the event identifier to complete the triggering of the combined event, enabling different event groups to reuse the same piece of code logic, meeting the requirements of high cohesion and low coupling, and thus improving the game development efficiency.

[0135] Based on the same inventive concept, referring to Figure 6 As shown, there is a schematic structural diagram of an electronic device 600 provided by an embodiment of the present application, including: a processor 610, a memory 620, and a bus 630. The memory 620 stores machine-readable instructions executable by the processor 610. When the electronic device 600 runs, communication is carried out between the processor 610 and the memory 620 through the bus 630. When the machine-readable instructions are run by the processor 610, the steps of the event processing method described in any one of the above embodiments are executed.

[0136] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: receiving a subscription request for a target combined event in a target event group sent by a first subscription object; the subscription request carries the event identifier of the target combined event and a first callback function; determining whether there is a target proxy object for recording the event trigger status identifier of the target event group; if so, determining whether to trigger the target combined event based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combined event; the current event trigger status identifier is obtained based on a historical event trigger status identifier and the event identifier of at least one event in the currently triggered target event group; if so, after triggering the target combined event, a notification message indicating that the target combined event has been triggered is sent to the first subscription object through the first callback function.

[0137] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: before receiving a subscription request for a target combined event in a target event group sent by a first subscription object, receiving an initialization request for the target event group sent by a second subscription object; the initialization request carries the group identifier of the target event group; creating the target proxy object.

[0138] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: receiving a trigger message sent by a target publishing object for any sub-event in the target event group; sending the trigger message to the target proxy object so that the target proxy object updates the event trigger status flag of the target event group.

[0139] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: after receiving a trigger message sent by a target publishing object for any sub-event in the target event group, traversing the callback function mapping table to determine a second callback function and a third subscription object associated with the event identifier of the sub-event; sending a notification message indicating that the sub-event has been triggered to the third subscription object through the second callback function.

[0140] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: obtaining the current event trigger status flag of the target event group recorded by the target proxy object; determining whether the current event trigger status flag is consistent with the event identifier of the target combined event; if they are consistent, determining that the target combined event is triggered.

[0141] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: receiving a notification message sent by the target proxy object indicating that the target combined event meets the trigger condition; the target proxy object determines that the trigger condition is met based on the consistency between the current event trigger status flag and the event identifier of the target combined event; determining that the target combined event is triggered.

[0142] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: determining the event identifier of the target combined event based on the event identifier of the first sub-event and the event identifier of the second sub-event.

[0143] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: performing an OR operation on the event identifier of the first sub-event and the event identifier of the second sub-event to determine the event identifier of the target combined event.

[0144] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: after determining whether there is a target proxy object for recording the event trigger status flag of the target event group, if not, creating the target proxy object.

[0145] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: after receiving a subscription request for a target combined event sent by the first event subscription object, query whether there is an event identifier of the target combined event in the callback function mapping table; if it exists, establish an association relationship between the first callback function and the event identifier of the target combined event and then store it in the callback function mapping table; if it does not exist, create a key-value pair with the event identifier of the target combined event as the key and an empty callback function list as the value, insert the first callback function at the end of the callback function list, and store the key-value pair in the callback function mapping table.

[0146] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing may be performed: receive an event status cleaning request for the target event group sent by the fourth subscription object; the event status cleaning request carries a group identifier of the target event group; send a reset message for the event trigger status identifier of the target combined event to the target proxy object.

[0147] In the embodiment of the present application, the interaction between the event system and the proxy object is realized through the event identifier to complete the triggering of the combined event, so that different event groups can reuse the same code logic, which can meet the requirements of high cohesion and low coupling, thereby improving the game development efficiency.

[0148] Based on the same inventive concept, the embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is run by a processor, it executes the steps of the event processing method provided in the above embodiment.

[0149] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, it can execute the above event processing method. After receiving a subscription request for a target combined event in a target event group sent by the first subscription object, it is judged whether there is a target proxy object for recording the event trigger status identifier of the target event group; if it exists, it is determined whether to trigger the target combined event based on the current event trigger status identifier and the event identifier of the target combined event; after triggering the target combined event, a notification message indicating that the target combined event is triggered is sent to the first subscription object through the first callback function. In this way, the present application realizes the interaction between the event system and the proxy object through the event identifier to complete the triggering of the combined event, so that different event groups can reuse the same code logic, which can meet the requirements of high cohesion and low coupling, thereby improving the game development efficiency.

[0150] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein. In several embodiments provided in the present 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 the units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the couplings or direct couplings or communication connections shown or discussed with each other can be through some communication interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

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

[0152] In addition, in each embodiment of the present application, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.

[0153] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or a part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.

[0154] It should be noted that like reference numerals and letters denote like items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used for descriptive distinction and should not be construed as indicating or implying relative importance or relative relationships.

[0155] Finally, it should be noted that the above-described embodiments are only specific embodiments of the present application, which are used to illustrate the technical solutions of the present application and are not intended to limit them. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that any person skilled in the art within the technical scope disclosed in the present application can still modify the technical solutions described in the foregoing embodiments or can easily think of changes, or perform equivalent replacements on some of the technical features; and these modifications, changes or replacements 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 the present application. All should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. An event handling method, characterized in that, The described event processing method includes: Receiving a subscription request sent by a first subscription object for a target combined event in a target event group; the subscription request carries an event identifier of the target combined event and a first callback function; Determining whether there is a target proxy object for recording an event trigger status identifier of the target event group; If there is, based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combined event, determining whether to trigger the target combined event; the current event trigger status identifier is obtained based on a historical event trigger status identifier and an event identifier of at least one event in the currently triggered target event group; If so, after triggering the target combined event, sending a notification message indicating that the target combined event has been triggered to the first subscription object through the first callback function.

2. The event processing method according to claim 1, wherein Before receiving the subscription request sent by the first subscription object for the target combined event in the target event group, the event processing method further includes: Receiving an initialization request sent by a second subscription object for the target event group; the initialization request carries a group identifier of the target event group; Creating the target proxy object; Wherein, the initial event trigger status identifier of the target event group recorded by the target proxy object is obtained based on the group identifier of the target event group.

3. The event processing method according to claim 1, characterized in that The event processing method further includes: Receiving a trigger message sent by a target publishing object for any sub-event in the target event group; Sending the trigger message to the target proxy object so that the target proxy object updates the event trigger status identifier of the target event group; Wherein, the trigger message carries an event identifier of the sub-event.

4. The event processing method according to claim 3, characterized in that, After receiving the trigger message sent by the target publishing object for any sub-event in the target event group, the event processing method further includes: Traversing a callback function mapping table to determine a second callback function and a third subscription object associated with the event identifier of the sub-event; Sending a notification message indicating that the sub-event has been triggered to the third subscription object through the second callback function.

5. The event processing method according to claim 1, characterized in that The determining whether to trigger the target combined event based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combined event includes: Obtaining the current event trigger status identifier of the target event group recorded by the target proxy object; Determining whether the current event trigger status identifier is consistent with the event identifier of the target combined event; If they are consistent, determining to trigger the target combined event.

6. The event processing method according to claim 1, characterized in that The determining whether to trigger the target combined event based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combined event includes: Receiving a notification message sent by the target proxy object indicating that the target combined event meets the trigger condition; the target proxy object determines that the trigger condition is met based on the consistency between the current event trigger status identifier and the event identifier of the target combined event; Determine to trigger the target combined event.

7. The event processing method according to claim 1, characterized in that The target event group further includes a first sub-event and a second sub-event; Generate an event identifier for the target combined event according to the following steps: Based on the event identifier of the first sub-event and the event identifier of the second sub-event, determine the event identifier of the target combined event; Wherein, the event identifier of any sub-event in the target event group includes the group identifier of the target event group and the sub-identifier of the sub-event.

8. The event processing method according to claim 7, wherein The event identifier is represented in digital binary form; The determining the event identifier of the target combined event based on the event identifier of the first sub-event and the event identifier of the second sub-event includes: Performing an OR operation on the event identifier of the first sub-event and the event identifier of the second sub-event to determine the event identifier of the target combined event.

9. The event processing method according to claim 1, wherein After determining whether there is a target proxy object for recording the event trigger status identifier of the target event group, the event processing method further includes: If not, create the target proxy object.

10. The event processing method according to claim 1, characterized in that, After receiving a subscription request for the target combined event sent by the first subscription object, the event processing method further includes: Query whether there is an event identifier of the target combined event in the callback function mapping table; If it exists, establish an association relationship between the first callback function and the event identifier of the target combined event and store it in the callback function mapping table; If it does not exist, create a key-value pair with the event identifier of the target combined event as the key and an empty callback function list as the value, insert the first callback function at the end of the callback function list, and store the key-value pair in the callback function mapping table.

11. The event processing method according to claim 1, characterized in that The event processing method further includes: Receive an event status cleaning request for the target event group sent by the fourth subscription object; the event status cleaning request carries the group identifier of the target event group; Send a reset message for the event trigger status identifier of the target combined event to the target proxy object.

12. An event processing device, characterized in that, The event processing device includes: A receiving module, configured to receive a subscription request for a target combined event in a target event group sent by a first subscription object; the subscription request carries the event identifier of the target combined event and a first callback function; A judging module, configured to judge whether there is a target proxy object for recording the event trigger status identifier of the target event group; A determining module, configured to, if there is the target proxy object, determine whether to trigger the target combined event based on the current event trigger status identifier of the target event group recorded by the target proxy object and the event identifier of the target combined event; the current event trigger status identifier is obtained according to the historical event trigger status identifier and the event identifier of at least one event in the currently triggered target event group; A first sending module, configured to, if it is determined to trigger the target combined event, after triggering the target combined event, send a notification message indicating that the target combined event is successfully triggered to the first subscription object through the first callback function.

13. An electronic device, characterized in that, Includes: A processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory through the bus, and when the machine-readable instructions are run by the processor, the steps of the event processing method according to any one of claims 1 to 11 are executed.

14. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the steps of the event processing method according to any one of claims 1 to 11 are executed.

Citation Information

Patent Citations

  • Registration method and system of subscription event and processing method and system of subscription event

    CN109981538A

  • Event subscription method, device and equipment

    CN112218272A