CN103995752A - Intermodule notification callback method and module interaction structure - Google Patents

Intermodule notification callback method and module interaction structure Download PDF

Info

Publication number
CN103995752A
CN103995752A CN201410266347.0A CN201410266347A CN103995752A CN 103995752 A CN103995752 A CN 103995752A CN 201410266347 A CN201410266347 A CN 201410266347A CN 103995752 A CN103995752 A CN 103995752A
Authority
CN
China
Prior art keywords
module
event
intermodule
public message
functional module
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
CN201410266347.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.)
Shanghai Feixun Data Communication Technology Co Ltd
Original Assignee
Shanghai Feixun Data Communication 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 Shanghai Feixun Data Communication Technology Co Ltd filed Critical Shanghai Feixun Data Communication Technology Co Ltd
Priority to CN201410266347.0A priority Critical patent/CN103995752A/en
Publication of CN103995752A publication Critical patent/CN103995752A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses an intermodule notification callback method. The method includes the steps that a common information module is established, and the common information module is connected with all function modules respectively; callback functions of events or response events of all the function modules are registered in the common information module; after the common information module receives the information sent from other function modules, all the callback functions of the events which are registered in advance are called, and accordingly interaction amoung the function modules can be achieved. According to the intermodule notification callback method, module interaction work is completed by one independent common information module in a unified mode, coupling of a plurality of modules is lowered, and a software system can be maintained easily; interaction among the modules can be achieved more simply only through simple registration in the common information module; a header file of the common information module is directly cited in all the modules in which interaction is needed, the inconsistent definition condition among the modules is avoided, and the stability of the system is improved.

Description

Intermodule notice callback method and module interactive structure
Technical field
The present invention relates to a kind of exchange technology, be specifically related to a kind of intermodule notice callback method and module interactive structure.
Background technology
In the Software for Design of complication system, multiple intermodules usually need collaborative interactive, and traditional method is " to set up message queue " or " registered callbacks function " at two mutual intermodules of needs.
As shown in Figure 1, if such as will be when the modules A generation event X function Y of calling module B.
The method of " setting up message queue " is: between modules A and module B, set up message queue, in the time of modules A generation event X, send message to module B, module B resolves this message and calls corresponding function.
The method of " registered callbacks function " is: function Y is registered as call back function by the module B registration function that first calling module A provides, then the call back function Y of meeting Automatically invoked module B registration in the time of modules A generation event X.
As shown in Figure 2, be the mutual topological diagram of classic method intermodule, suppose to have five modules, need between between two mutual.In visible five modules, four modules of each module and all the other connect.
The shortcoming of prior art is:
1), every two mutual intermodules all need to set up a message queue or registration a call back function, realize more complicated.
2), increased the coupling of intermodule, the amendment of a module can cause multiple relevant modules also must amendment, is difficult to safeguard.
3), two mutual intermodules, if both sides interface definition is inconsistent, the mistake may cause moving time, affects the stability of system.
Summary of the invention
The invention provides a kind of intermodule notice callback method and module interactive structure, reduce intermodule coupling, system is easy to safeguard, improves system stability.
For achieving the above object, the invention provides a kind of intermodule notice callback method, be characterized in, the method comprises:
Set up a public message module, and connect with each functional module respectively;
Each functional module in public message module registered events or registration response events call back function;
Receive after the message that other functional modules send when public message module, call call back functions all in the event of registered in advance, to complete mutual between functional module.
Above-mentioned public message module includes header file and source file;
In header file, define event id and call back function pointer type;
In source file, create message queue, the two-dimensional array of an overall function pointer of definition.
The one dimension subscript of above-mentioned two-dimensional array represents event id, and two-dimentional subscript representative is registered in the call back function on corresponding event id;
In conjunction with one dimension subscript and the two-dimentional subscript addressing of two-dimensional array, obtain being registered in target event id under this one dimension all call back functions in corresponding event.
The method of above-mentioned functions module registered events in public message module comprises:
Need the functional module of registered events to add the macro definition of an event id at the header file of public message module, and add the definition of the structure parameter that will pass to call back function.
The method of the call back function of the corresponding event of above-mentioned functions module registration response comprises:
This functional module is by the position of corresponding event id in the two-dimensional array of the pointer address input public message module of call back function.
The exchange method of above-mentioned functions intermodule comprises:
One functional module is initiated an event, sends message to the message queue of public message module, in this message, comprises event id;
Public message module is resolved after receiving this message, obtains the structure parameter of this event id;
Then call every other functional module in the call back function of this event of response of public message module registration.
Repeat the exchange method of above-mentioned functions intermodule, complete mutual between some functional modules; The header file that the mutual functional module of all participations comprises public message module.
A module interactive structure that is applicable to above-mentioned intermodule notice callback method, includes some functional modules in this structure; Be characterized in, this structure also includes public message module, and some functional modules are connected to respectively described public message module; Each functional module, each other without connecting, completes between functional module mutual by public message module.
The intermodule interactive mode of intermodule notice callback method of the present invention and module interactive structure and prior art is compared, its advantage is, the present invention by work unification mutual module by one independently public message module complete, reduced the coupling of multiple intermodules, make software systems be easy to safeguard;
Intermodule of the present invention mutual only need to do simple registration in public message module, realizes simpler and easy;
The mutual module of all needs of the present invention is all directly quoted public message module header file, has avoided intermodule to define inconsistent situation, has promoted the stability of system.
Brief description of the drawings
Fig. 1 is the mutual schematic diagram of prior art intermodule;
Fig. 2 is the mutual topological diagram of prior art intermodule;
Fig. 3 is the topological diagram of module interactive structure of the present invention;
Fig. 4 is the method flow diagram of intermodule notice callback method of the present invention;
Fig. 5 is the schematic diagram of function pointer two-dimensional array in intermodule notice callback method of the present invention.
Embodiment
Below in conjunction with accompanying drawing, further illustrate specific embodiments of the invention.
As shown in Figure 3, the present invention discloses a kind of module interactive structure, includes some functional modules in this structure, respectively: modules A, module B, module C, module D, module E, these five functional modules are each other without connecting.This module interactive structure also comprises a public message module F, and this public message module F sets up to have with above-mentioned five functional modules respectively and is connected, and these five functional modules complete mutual between each functional module by public message module F.
As shown in Figure 4, the present invention discloses a kind of intermodule notice callback method, and the method includes the steps of:
Step 1, set up a public message module, this public message module connects with each functional module respectively.Public message module includes header file comonMSG .h and source file comonMSG .c.Header file comonMSG .h is for definition (or establishment) " event id " and call back function pointer type.
Step 2, in the source file comonMSG of public message module .c, create message queue processMSG, for " event " message of receiving module.
As shown in Figure 5, in the source file of public message module, create the two-dimensional array of an overall function pointer, this two-dimensional array is for storage event and corresponding call back function simultaneously.The one dimension subscript representative " event id " of this two-dimensional array, two-dimentional subscript represents concrete variable, is combined into a function that pointed is concrete by one dimension subscript and two-dimentional subscript.In two-dimensional array, storage is registered in the call back function in corresponding event.In conjunction with one dimension subscript and the two-dimentional subscript addressing of two-dimensional array, can obtain being registered in target under this one dimension " event id " all call back functions in corresponding event.
Step 3, each functional module in public message module registered events or registration response events call back function.
When a functional module (calling functional module A in the following text) need to be added an event, add the macro definition of an event id at the header file comonMSG of public message module .h, and add the definition of the structure parametric t mp that will pass to call back function.In the time there is this event, this functional module needs to send message to the message queue processMSG of public message module, in message, comprise this event id, for example " Module_A_Event_1 ", and its type of structure parametric t mp(is Module_A_Event_1_Parameter).
When a functional module need to be added the call back function of the event of a response corresponding function module, for example another functional module (calling functional module B in the following text) need to be added the call back function of the corresponding event of event id " Module_A_Event_1 " that a response above-mentioned functions modules A adds, directly by this call back function of functional module B, for example Module_B_Callback_1(void * temp), address insert the position of the event id that in two-dimensional array, corresponding function modules A is added (two-dimensional array one dimension subscript).
Step 4, receive after the message that other functional modules send when public message module, call call back functions all in the event of registered in advance, to complete mutual between functional module.
Step 4.1, a functional module are initiated an event, and for example the event of above-mentioned its registration occurs functional module A, send message to the message queue processMSG of public message module, comprise event id " Module_A_Event_1 " in this message.
Step 4.2, public message module are resolved after receiving this message, obtain the structure parametric t mp of this event id.
Step 4.3, then call every other functional module in the call back function Module_B_Callback_1(void * temp of this event of response of public message module registration).
To step 4, complete mutual between two functional modules (functional module A and functional module B) by above-mentioned steps 1.
Repeat above-mentioned steps 1 to the exchange method between the functional module of step 4, can complete mutual between some functional modules; The header file comonMSG. h that the mutual functional module of all participations comprises public message module.
Although content of the present invention has been done detailed introduction by above preferred embodiment, will be appreciated that above-mentioned description should not be considered to limitation of the present invention.Read after foregoing those skilled in the art, for multiple amendment of the present invention and substitute will be all apparent.Therefore, protection scope of the present invention should be limited to the appended claims.

Claims (8)

1. an intermodule notice callback method, is characterized in that, the method comprises:
Set up a public message module, and connect with each functional module respectively;
Each functional module in public message module registered events or registration response events call back function;
Receive after the message that other functional modules send when public message module, call call back functions all in the event of registered in advance, to complete mutual between functional module.
2. intermodule notice callback method as claimed in claim 1, is characterized in that, described public message module includes header file and source file;
In header file, define event id and call back function pointer type;
In source file, create message queue, the two-dimensional array of an overall function pointer of definition.
3. intermodule notice callback method as claimed in claim 2, is characterized in that, the one dimension subscript of described two-dimensional array represents event id, and two-dimentional subscript representative is registered in the call back function on corresponding event id;
In conjunction with one dimension subscript and the two-dimentional subscript addressing of two-dimensional array, obtain being registered in target event id under this one dimension all call back functions in corresponding event.
4. intermodule notice callback method as claimed in claim 2, is characterized in that, the method for described functional module registered events in public message module comprises:
Need the functional module of registered events to add the macro definition of an event id at the header file of public message module, and add the definition of the structure parameter that will pass to call back function.
5. intermodule notice callback method as claimed in claim 2, is characterized in that, the method for the call back function of the corresponding event of described functional module registration response comprises:
This functional module is by the position of corresponding event id in the two-dimensional array of the pointer address input public message module of call back function.
6. intermodule notice callback method as claimed in claim 2, is characterized in that, the exchange method between described functional module comprises:
One functional module is initiated an event, sends message to the message queue of public message module, in this message, comprises event id;
Public message module is resolved after receiving this message, obtains the structure parameter of this event id;
Then call every other functional module in the call back function of this event of response of public message module registration.
7. intermodule as claimed in claim 6 notice callback method, is characterized in that, repeats the exchange method between described functional module, completes mutual between some functional modules; The header file that the mutual functional module of all participations comprises public message module.
8. a module interactive structure that is applicable to intermodule notice callback method as described in any one claim in claim 1 to 7, includes some functional modules in this structure; It is characterized in that, this structure also includes public message module, and some functional modules are connected to respectively described public message module; Each functional module, each other without connecting, completes between functional module mutual by public message module.
CN201410266347.0A 2014-06-16 2014-06-16 Intermodule notification callback method and module interaction structure Pending CN103995752A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410266347.0A CN103995752A (en) 2014-06-16 2014-06-16 Intermodule notification callback method and module interaction structure

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410266347.0A CN103995752A (en) 2014-06-16 2014-06-16 Intermodule notification callback method and module interaction structure

Publications (1)

Publication Number Publication Date
CN103995752A true CN103995752A (en) 2014-08-20

Family

ID=51309926

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410266347.0A Pending CN103995752A (en) 2014-06-16 2014-06-16 Intermodule notification callback method and module interaction structure

Country Status (1)

Country Link
CN (1) CN103995752A (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104794010A (en) * 2015-04-29 2015-07-22 中国人民解放军国防科学技术大学 Optimization method for information interaction in system
CN105739967A (en) * 2016-01-19 2016-07-06 四川长虹电器股份有限公司 Method of asynchronously calling native by js in mobile application
CN106339217A (en) * 2016-08-18 2017-01-18 福建天泉教育科技有限公司 Event management method and system based on Unity
CN106919713A (en) * 2017-03-13 2017-07-04 郑州云海信息技术有限公司 A kind of cluster file system and distributed file system multi-client document control method
CN107133025A (en) * 2017-03-16 2017-09-05 武汉斗鱼网络科技有限公司 A kind of response method and device
CN107402769A (en) * 2017-08-09 2017-11-28 郑州云海信息技术有限公司 A kind of method and system of module information interaction
CN107515793A (en) * 2017-08-22 2017-12-26 四川长虹电器股份有限公司 A kind of module communication means for supporting message mechanism
CN107632885A (en) * 2017-09-26 2018-01-26 郑州云海信息技术有限公司 The readjustment management method and device of inter-module
CN109739661A (en) * 2018-12-27 2019-05-10 苏州思必驰信息科技有限公司 The method, apparatus and system of information updating between a kind of cooperative module
CN110413271A (en) * 2019-07-26 2019-11-05 福建省天奕网络科技有限公司 Smart message management method based on Unity3D life cycle
CN110489041A (en) * 2019-07-12 2019-11-22 北京字节跳动网络技术有限公司 Method, apparatus, equipment and the medium of small routine dragging element automatic aligning
CN110659033A (en) * 2018-06-29 2020-01-07 武汉斗鱼网络科技有限公司 Protocol registration and distribution method, storage medium, electronic device and system
CN110928797A (en) * 2019-11-29 2020-03-27 五八有限公司 Code coupling detection method and device, terminal equipment and storage medium
CN113253894A (en) * 2021-05-24 2021-08-13 北京牛电信息技术有限责任公司 Vehicle data interaction method, device, equipment and storage medium
CN117632312A (en) * 2024-01-25 2024-03-01 深圳市永联科技股份有限公司 Data interaction method and related device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101620536A (en) * 2009-08-17 2010-01-06 用友软件股份有限公司 Method and device for invoking performance function
US20100070982A1 (en) * 2005-09-09 2010-03-18 Pitts William M Distributed File System Consistency Mechanism Extension For Accelerating Communications Between Distributed Applications
CN102402457A (en) * 2010-09-17 2012-04-04 希姆通信息技术(上海)有限公司 Method for processing mobile phone application program alterative events
CN102546718A (en) * 2010-12-31 2012-07-04 上海可鲁系统软件有限公司 Software configuration method for functional modules in distributed platform
CN102866925A (en) * 2012-09-06 2013-01-09 深圳市九洲电器有限公司 Communication method and system for middleware and user interface

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100070982A1 (en) * 2005-09-09 2010-03-18 Pitts William M Distributed File System Consistency Mechanism Extension For Accelerating Communications Between Distributed Applications
CN101620536A (en) * 2009-08-17 2010-01-06 用友软件股份有限公司 Method and device for invoking performance function
CN102402457A (en) * 2010-09-17 2012-04-04 希姆通信息技术(上海)有限公司 Method for processing mobile phone application program alterative events
CN102546718A (en) * 2010-12-31 2012-07-04 上海可鲁系统软件有限公司 Software configuration method for functional modules in distributed platform
CN102866925A (en) * 2012-09-06 2013-01-09 深圳市九洲电器有限公司 Communication method and system for middleware and user interface

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104794010B (en) * 2015-04-29 2018-02-16 中国人民解放军国防科学技术大学 Information exchange optimization method in a kind of system
CN104794010A (en) * 2015-04-29 2015-07-22 中国人民解放军国防科学技术大学 Optimization method for information interaction in system
CN105739967A (en) * 2016-01-19 2016-07-06 四川长虹电器股份有限公司 Method of asynchronously calling native by js in mobile application
CN106339217A (en) * 2016-08-18 2017-01-18 福建天泉教育科技有限公司 Event management method and system based on Unity
CN106919713A (en) * 2017-03-13 2017-07-04 郑州云海信息技术有限公司 A kind of cluster file system and distributed file system multi-client document control method
CN106919713B (en) * 2017-03-13 2021-03-16 苏州浪潮智能科技有限公司 Cluster file system and distributed file system multi-client file control method
CN107133025A (en) * 2017-03-16 2017-09-05 武汉斗鱼网络科技有限公司 A kind of response method and device
CN107402769A (en) * 2017-08-09 2017-11-28 郑州云海信息技术有限公司 A kind of method and system of module information interaction
CN107515793A (en) * 2017-08-22 2017-12-26 四川长虹电器股份有限公司 A kind of module communication means for supporting message mechanism
CN107632885A (en) * 2017-09-26 2018-01-26 郑州云海信息技术有限公司 The readjustment management method and device of inter-module
CN110659033A (en) * 2018-06-29 2020-01-07 武汉斗鱼网络科技有限公司 Protocol registration and distribution method, storage medium, electronic device and system
CN110659033B (en) * 2018-06-29 2023-08-11 深圳耐看科技有限公司 Protocol registration distribution method, storage medium, electronic equipment and system
CN109739661B (en) * 2018-12-27 2021-06-22 思必驰科技股份有限公司 Method, device and system for updating messages between collaborative modules
CN109739661A (en) * 2018-12-27 2019-05-10 苏州思必驰信息科技有限公司 The method, apparatus and system of information updating between a kind of cooperative module
CN110489041A (en) * 2019-07-12 2019-11-22 北京字节跳动网络技术有限公司 Method, apparatus, equipment and the medium of small routine dragging element automatic aligning
CN110413271A (en) * 2019-07-26 2019-11-05 福建省天奕网络科技有限公司 Smart message management method based on Unity3D life cycle
CN110413271B (en) * 2019-07-26 2022-04-05 福建省天奕网络科技有限公司 Intelligent message management method based on Unity3D life cycle
CN110928797A (en) * 2019-11-29 2020-03-27 五八有限公司 Code coupling detection method and device, terminal equipment and storage medium
CN113253894A (en) * 2021-05-24 2021-08-13 北京牛电信息技术有限责任公司 Vehicle data interaction method, device, equipment and storage medium
CN117632312A (en) * 2024-01-25 2024-03-01 深圳市永联科技股份有限公司 Data interaction method and related device
CN117632312B (en) * 2024-01-25 2024-05-14 深圳市永联科技股份有限公司 Data interaction method and related device

Similar Documents

Publication Publication Date Title
CN103995752A (en) Intermodule notification callback method and module interaction structure
US10949158B2 (en) Screenshot method and apparatus
TWI696079B (en) Multi-blockchain network data processing method, device and server
CN106850788B (en) Integrated framework and integrated approach towards multi-source heterogeneous geographic information resources
WO2018076759A1 (en) Block chain-based multi-chain management method and system, electronic device, and storage medium
WO2019072280A3 (en) Executing multi-party transactions using smart contracts
JP2019092147A (en) Information exchanging method and device, audio terminal, and computer-readable storage medium
WO2019205555A1 (en) Method and apparatus for pushing message
CN110582998A (en) Group communication method and device, computer storage medium and computer equipment
CN104219269A (en) Synchronous remote consultation method and synchronous remote consultation system
CN104811922A (en) Adjacent node registration method and the device and cross-node registration method and system
CN104796389A (en) Basic data sharing system and method thereof
CN112994981B (en) Method and device for adjusting time delay data, electronic equipment and storage medium
WO2016070810A1 (en) Method for a dual access application between two execution environments
CN113792347A (en) Block chain-based federal learning method, device, equipment and storage medium
CN104202506A (en) Image stitching processor and image processing method thereof
CN104901815A (en) Grouping method for user terminals, conference server and conference system
CN104144202A (en) Hadoop distributed file system access method, system and device
CN110784517B (en) Service application integration method, system, terminal and storage medium based on block chain
CN105306273A (en) Process configuration method and device
CN104219284A (en) Server designing method based on semi-synchronization, semi-synchronization and pipe filter mode
CN112711625B (en) Bidirectional self-adaptive multi-source heterogeneous big data dynamic processing method
EP3267655A1 (en) Multi-terminal interaction relation maintenance system and method
CN103561113A (en) Web Service interface generating method and device
CN106095739A (en) Information creating method and information creating device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20140820