Summary of the invention
For defect of the prior art, the invention provides a kind of method and device of multiwindow inter-component communication, achieve the information transmission between multicompartment under multi-windowed environment, and then the multithreading JavaScript collaborative work achieved based on multiwindow, and finally solve due to the performance of front end problem that single-threaded JavaScript performs and UI plays up mutual the obstruction and causes.
First aspect, the invention provides a kind of device of multiwindow inter-component communication, comprising:
Acquisition module, for when receiving the first message event of first window, according to described first message event, obtain the triggered target that described first message event is corresponding, and the operational order of described triggered target, described triggered target is at least one assembly of more than one Second Window;
Release module, for issuing described operational order to described triggered target, performs operation corresponding to described operational order to make described triggered target.
Optionally, described device also comprises:
First receiver module, for when first window issues the first message event, receives the first message event of described first window.
Optionally, described device also comprises:
Second receiver module, the second message event that the assembly for receiving more than one Second Window is subscribed to;
Described release module, specifically for:
When the assembly of described more than one Second Window corresponding to described triggered target and described second message event is consistent, described operational order issued by the assembly to described more than one Second Window.
Optionally, described device also comprises:
Window identifier adds module, and for adding window identifier for described first window and more than one Second Window, described more than one Second Window subscribes to described second message event by described window identifier,
And/or,
Described acquisition module, specifically for:
When receiving the first message event of first window, obtain the window identifier of triggered target corresponding to described first window;
Described release module, specifically for:
Described operational order is issued to the triggered target corresponding with described window identifier according to described window identifier.
Optionally, described device also comprises:
Memory module, for storing described first message event,
Described memory module, specifically for:
After described release module issues described operational order, when described first window or more than one Second Window are closed, the state of the assembly of described first window or more than one Second Window is preserved, when being opened to make the assembly of described first window or more than one Second Window, the end-state that the assembly showing described first window or more than one Second Window is preserved.
Optionally, described first message event or described second message event comprise following at least one:
The event of allocation window attribute, touch-control event, command event.
Second aspect, present invention also offers a kind of method of multiwindow inter-component communication, comprising:
When receiving the first message event of first window, according to described first message event, obtain the triggered target that described first message event is corresponding, and the operational order of described triggered target, described triggered target is at least one assembly of more than one Second Window;
Issue described operational order to described triggered target, perform operation corresponding to described operational order to make described triggered target.
Optionally, described method also comprises:
When first window issues the first message event, receive the first message event of described first window.
Optionally, described method also comprises:
The second message event that the assembly receiving more than one Second Window is subscribed to;
Correspondingly, issue described operational order to described triggered target, comprising:
When the assembly of described more than one Second Window corresponding to described triggered target and described second message event is consistent, described operational order issued by the assembly to described more than one Second Window.
Optionally, described method also comprises:
For described first window and more than one Second Window add window identifier, described more than one Second Window subscribes to described second message event by described window identifier,
And/or,
When receiving the first message event of first window, obtain the window identifier of triggered target corresponding to described first window,
Correspondingly, issue described operational order to described triggered target, comprising:
Described operational order is issued to the triggered target corresponding with described window identifier according to described window identifier.
Optionally, described method also comprises:
Store described first message event,
Accordingly, issuing described operational order to described triggered target, to make after described triggered target performs operation corresponding to described operational order, described method also comprises:
When described first window or more than one Second Window are closed, the state of the assembly of described first window or more than one Second Window is preserved, when being opened to make the assembly of described first window or more than one Second Window, the end-state that the assembly showing described first window or more than one Second Window is preserved.
Optionally, described first message event or described second message event comprise following at least one:
The event of allocation window attribute, touch-control event, command event.
As shown from the above technical solution, the method of a kind of multiwindow inter-component communication provided by the invention and device, the method is by receiving the first message event of first window, obtain the triggered target that this first message event is corresponding, and the operational order of this triggered target, and issue operational order to this triggered target, the assembly of Second Window corresponding to this triggered target is made to perform operation corresponding to this operational order, the method achieve effective transmission of information between multiwindow assembly, improve the experience of user.
In instructions of the present invention, describe a large amount of detail.But can understand, embodiments of the invention can be put into practice when not having these details.In some instances, be not shown specifically known method, structure and technology, so that not fuzzy understanding of this description.
Similarly, be to be understood that, to disclose and to help to understand in each inventive aspect one or more to simplify the present invention, in the description above to exemplary embodiment of the present invention, each feature of the present invention is grouped together in single embodiment, figure or the description to it sometimes.But, the method for the disclosure should not explained the following intention in reflection: namely the present invention for required protection requires feature more more than the feature clearly recorded in each claim.Or rather, as claims below reflect, all features of disclosed single embodiment before inventive aspect is to be less than.Therefore, the claims following embodiment are incorporated to this embodiment thus clearly, and wherein each claim itself is as independent embodiment of the present invention.
It will be understood by those skilled in the art that adaptively to change the module in the equipment in embodiment and they are arranged and be in one or more equipment that this embodiment is different.Module in embodiment or unit or assembly can be combined into a module or unit or assembly, and multiple submodule or subelement or sub-component can be put them in addition.Except at least some in such feature and/or process or unit is mutually exclusive part, any combination can be adopted to combine all processes of all features disclosed in this instructions (comprising adjoint claim, summary and accompanying drawing) and so disclosed any method or equipment or unit.Unless expressly stated otherwise, each feature disclosed in this instructions (comprising adjoint claim, summary and accompanying drawing) can by providing identical, alternative features that is equivalent or similar object replaces.
In addition, those skilled in the art can understand, although embodiments more described herein to comprise in other embodiment some included feature instead of further feature, the combination of the feature of different embodiment means and to be within scope of the present invention and to form different embodiments.Such as, in the following claims, the one of any of embodiment required for protection can use with arbitrary array mode.
All parts embodiment of the present invention with hardware implementing, or can realize with the software module run on one or more processor, or realizes with their combination.It will be understood by those of skill in the art that the some or all functions that microprocessor or digital signal processor (DSP) can be used in practice to realize according to the some or all parts in the equipment of a kind of browser terminal of the embodiment of the present invention.The present invention can also be embodied as part or all equipment for performing method as described herein or device program (such as, computer program and computer program).Realizing program of the present invention and can store on a computer-readable medium like this, or the form of one or more signal can be had.Such signal can be downloaded from internet website and obtain, or provides on carrier signal, or provides with any other form.
The present invention will be described instead of limit the invention to it should be noted above-described embodiment, and those skilled in the art can design alternative embodiment when not departing from the scope of claims.In the claims, any reference symbol between bracket should be configured to limitations on claims.Word " comprises " not to be got rid of existence and does not arrange element in the claims or step.Word "a" or "an" before being positioned at element is not got rid of and be there is multiple such element.The present invention can by means of including the hardware of some different elements and realizing by means of the computing machine of suitably programming.In the unit claim listing some devices, several in these devices can be carry out imbody by same hardware branch.Word first, second and third-class use do not represent any order.Can be title by these word explanations.
Last it is noted that above each embodiment is only in order to illustrate technical scheme of the present invention, be not intended to limit; Although with reference to foregoing embodiments to invention has been detailed description, those of ordinary skill in the art is to be understood that: it still can be modified to the technical scheme described in foregoing embodiments, or carries out equivalent replacement to wherein some or all of technical characteristic; And these amendments or replacement, do not make the essence of appropriate technical solution depart from the scope of various embodiments of the present invention technical scheme, it all should be encompassed in the middle of the scope of claim of the present invention and instructions.
Embodiment
Below in conjunction with accompanying drawing, the embodiment of invention is further described.Following examples only for technical scheme of the present invention is clearly described, and can not limit the scope of the invention with this.
Multiple assembly is shown at same browser window in order to solve, the execution of JavaScript and UI play up the problem of mutually blocking, the present invention adopt create multiple complete and independently UI thread share out the work and help one another, wherein each thread is responsible for the part work of whole application program, from then on solve and show multiple assembly at same browser window, the execution of JavaScript and UI play up the problem of mutually blocking.
Have employed in a browser for an independently UI thread opened by each window based on above-mentioned thought the application, in addition, each window has again an independently JavaScript execution environment, and the JavaScript under this environment has complete page turning capability.Therefore, by opening multiple window, and in these windows, run same application program achieve multiple threads.But said method also needs a set of traffic carried, and mechanism ensures that the inter-module of data in multiple window effectively transmits.The embodiment of the present invention is described in detail for the communication carrying out the inter-module of multiwindow in browser this locality.
Fig. 1 shows the schematic flow sheet of the method for the multiwindow inter-component communication that the embodiment of the present invention provides, and as shown in Figure 1, the method for this multiwindow inter-component communication comprises the steps:
101, when receiving the first message event of first window, according to described first message event, obtain the triggered target that described first message event is corresponding, and the operational order of described triggered target, described triggered target is at least one assembly of more than one Second Window.
For example, the client of the communications applications of the multiwindow inter-module that the embodiment of the present invention provides is existing touch-type electronic equipment, and can certainly be other non-tactile type electronic equipments, the present invention be restricted this.
Will be understood that, above-mentioned first window can be understood as the window of the event of giving out information, and more than one Second Window is the window subscribing to this message event.
The operational order of the triggered target that this message event is corresponding and this triggered target can be known in above-mentioned first message event, wherein, triggered target can be understood as the assembly of the window subscribing to this message event, the window subscribing to this message event can for one or more, the assembly of each window and be at least.
The operational order of described triggered target can be understood as the operations such as allocation window attribute, touch-control, order, such as, the attribute of allocation window can comprise size, the position and renewal frequency etc. of allocation window size, touch control operation can comprise the operation such as operation, screen locking, unblock, time-out, broadcasting that slip performs next step, order can comprise by modes such as voice, make these voice of window identification, to perform corresponding operation.
102, issue described operational order to described triggered target, perform operation corresponding to described operational order to make described triggered target.
For example, if above-mentioned more than one Second Window all have subscribed above-mentioned message event, then the triggered target in step 102 is all windows, and passes through the operational order of this message event obtained, issue to all windows, make all windows all perform corresponding operation according to this operational order.
Such as each window performs the operations such as allocation window attribute, touch-control, order according to the operational order of message event.
Fig. 2 shows the schematic flow sheet of the method for the multiwindow inter-component communication that the embodiment of the present invention provides, and as shown in Figure 2, the method for this multiwindow inter-component communication comprises the steps:
201, the second message event that the assembly receiving more than one Second Window is subscribed to;
The assembly that the assembly of above-mentioned Second Window can be understood as all windows also can be the assembly of one or more windows.
In a particular application, the telecommunication media of the assembly of above-mentioned window also can be subscribed to and the event that gives out information for browser this locality stores for server, can also be that other modes store the message event of subscribing to and issuing, but because the communication of the inter-module at server end multiwindow depends on network, and also not as communicating in browser this locality in communication speed, therefore, the embodiment of the present invention is described in detail for the communication carrying out the inter-module of multiwindow in browser this locality, but what the embodiment of the present invention was taked is a preferred mode, do not limit the telecommunication media of multiwindow inter-module of the present invention.
Local at browser for telecommunication media, the assembly of above-mentioned Second Window is to browser local subscription second message event, and this message event comprises event, touch-control event, the command event of allocation window attribute.Such as, when this message event is the event of allocation window attribute, can be understood as when other have arbitrary window to have an operation of allocation window attribute, then the window of this this message event of subscription also can carry out the operation of real-time allocation window attribute; When this message event is touch-control event such as screen locking event, then can be understood as when other have arbitrary window to have a touch-control event, then the operation etc. carrying out screen locking that the window subscribing to this message event also can be real-time.
In another attainable mode, the assembly of Second Window is before subscription second message event, and all windows all can add window identifier, and subscribes to described second message event by described window identifier.
The schematic diagram of the second message event of the assembly subscription of Second Window as shown in Figure 3A, this C1 and C2 is the assembly of window 1, S1 and S2 is the assembly of window 2, T1 is the assembly of window 3, if the assembly C1 in window 1 is the assembly of the event that gives out information, C2, S1, S2, T1 is respectively the assembly of subscribe message event, due to the assembly that C1 and C2 is in the same window, C2 can directly to C1 subscribe message event, for the assembly that S1 and S2 is window 2, T1 is the assembly of window 3, S1, S2, T1 can not directly to C1 subscribe message event, then S1, S2, T1 needs to act on behalf of the direct subscribe message event of publisher to respective window.Above-mentioned C1, C2, S1, S2, T1 assembly can be understood as and realizes some functions and define, and such as navigation menu, search column, news list etc., the embodiment of the present invention does not limit said modules.
202, when first window issues the first message event, the first message event of described first window is received.
Will be understood that, before first window issues the first message event, also can add window identifier at this window, when issue the first message event, carry this window indications.
Concrete, the first message event of the reception first window that the telecommunication media of the assembly of above-mentioned window is real-time, this first message event can be understood as the message event that certain window triggers certain operation.
203, when receiving the first message event of first window, according to described first message event, obtain the triggered target that described first message event is corresponding, and the operational order of described triggered target, described triggered target is at least one assembly of more than one Second Window.
For example, if the telecommunication media of the assembly of above-mentioned window receive the first message event time, obtain the operational order that the triggered target of the correspondence of this first message event and window indications and this triggered target are corresponding.
Above-mentioned triggered target is the assembly subscribing to these other windows of message event, and aforesaid operations instruction is trigger the assembly subscribing to these other windows of message event to perform corresponding operation.
Will be understood that, above-mentioned triggered target can be the component communication between multiple windows of the same client of same browser, and such as first window performs the operation of screen locking, then other windows subscribing to this message event also can perform this screen locking operation accordingly.
The communication of the inter-module of above-mentioned multiple window is not limited to assembly in the same window or the communication of the inter-module in different windows.It should be noted that, if be positioned at the communication of the inter-module of the same window, then do not need the transmission of telecommunication media, the subscription that the inter-module directly in this window carries out message event and issue complete communicating of different inter-module in the same window; If the communication of the inter-module in different windows, separate between JavaScript execution environment due to each window in browser, directly can not communicate, therefore need to be communicated by above-mentioned telecommunication media, realize the data transmission of different windows inter-module.
It should be noted that, in order to realize the cooperation between multithreading and multiwindow, need for each window adds window indications, this window indications can in a program by arranging a field as its ID, the communication mechanism depended between this window is caused to paralyse in order to prevent this ID to be mistakenly rewritten, cannot communicate normally, therefore be read-only when arranging this ID by its setup of attribute.
204, issue described operational order to described triggered target, perform operation corresponding to described operational order to make described triggered target.
Concrete, before issuing described operational order to described triggered target, when the assembly of described more than one Second Window corresponding to described triggered target and described second message event is consistent, described operational order issued by the assembly to described more than one Second Window.
Will be understood that, telecommunication media is when receiving the first message event of first window, obtain the window identifier of triggered target corresponding to described first window, issue described operational order according to described window identifier to the triggered target corresponding with described window identifier.
The second message event that more than one Second Window is subscribed to is stored in above-mentioned telecommunication media, the operational order of above-mentioned first message event and the second message event of subscription consistent time, or when the triggered target that above-mentioned first message event is corresponding is consistent with the window indications of the second message event of subscription, then described operational order issued by the assembly to the window of subscription second message event.
The present embodiment does not limit the order of above-mentioned steps, a just best embodiment, after receiving the first message event of first window in such as above-mentioned steps 202, store the first message event of this first window, and then perform the second message event that above-mentioned steps 210 receives the assembly subscription of more than one Second Window, the first message event of issuing of second message event of subscribing to when the assembly of this more than one Second Window and the first window of storage to time corresponding this the first message event issued by assembly then to more than one Second Window, the operation corresponding to the operational order in the first message event is performed to make the assembly of Second Window.
The schematic diagram of the first message event issued by the assembly of first window as shown in Figure 3 B, when the assembly C1 of window 1 gives out information event, directly can not send the assembly of other windows outside window 1, therefore need the message event that the assembly C1 of above-mentioned telecommunication media receive window 1 issues.This telecommunication media and browser this locality can store this first message event, and in above-mentioned steps 201 act on behalf of that publisher can be real-time catch the message event be stored in telecommunication media, when the present age, reason publisher detected the message event that message event in this telecommunication media subscribes to for assembly that this is acted on behalf of in the window corresponding to publisher, then directly obtain the message event be stored in telecommunication media, and this message event is distributed to corresponding assembly.
Fig. 4 A to Fig. 4 D shows the schematic diagram realizing the communication between each window assembly based on touch-control event.
Fig. 4 A is the schematic diagram before multiwindow page locking, suppose that window 2 and window 3 have subscribed touch-control event to the publisher that acts on behalf of that each window is corresponding, user is in window 1 slide downward, according to setting, specify that the operational order of this slide downward is page locking or cancels page locking, and the touch object of this mode of operation is all component of all windows, because all windows were originally all in the state of non-locking, so according to the operation of this user in window 1 slide downward, the touch-control event that telecommunication media meeting receive window 1 is issued, and now, act on behalf of after publisher detects this touch-control event, obtain the touch-control event of window 1 issue stored at telecommunication media, to make this window 2 and window 3 after this touch-control event issued by window 1, also can real-time execution operate accordingly, Fig. 4 B is the schematic diagram after multiwindow page locking, the page of namely all windows is all in the lock state.
Similar, as shown in Figure 4 C, for the multiwindow page cancels the schematic diagram before locking, user is by performing the operation of slide downward at window 1, the touch-control event that telecommunication media meeting receive window 1 is issued, and now, act on behalf of after publisher detects this touch-control event, obtain the touch-control event of window 1 issue stored at telecommunication media, to make this window 2 and window 3 after this touch-control event issued by window 1, also can real-time execution operate accordingly, because original all windows are all in the lock state, therefore according to window 1 issue touch-control event after, all windows all perform the operation cancelling locking, Fig. 4 D is the schematic diagram after the multiwindow page cancels locking, the page of namely all windows is all in unlocked state.
In a particular application, said method also comprises unshowned step 205 in Fig. 2.
The embodiment of the present invention is not limited to the communication mode between above-mentioned multiwindow assembly, in another mode in the cards, above-mentioned communication between same browser the same window also uses, but has lacked above-mentioned telecommunication media, and two inter-modules of the same window can directly communicate.
205, described operational order is being issued in above-mentioned steps to described triggered target, to make after described triggered target performs operation corresponding to described operational order, when described first window or more than one Second Window are closed, the state of the assembly of described first window or more than one Second Window is preserved, when being opened to make the assembly of described first window or more than one Second Window, the end-state that the assembly showing described first window or more than one Second Window is preserved.
Fig. 4 A is the schematic diagram before multiwindow page locking, as the schematic diagram that Fig. 4 B is after multiwindow page locking, and Fig. 4 B performs the schematic diagram after touch control operation command operating, after multiple closes of Fig. 4 B, when reopening again, still be the state of Fig. 4 B, and the state of Fig. 4 A can not be kept.
Fig. 5 shows the structural representation of the device of a kind of multiwindow inter-component communication that the embodiment of the present invention provides, and as shown in Figure 5, the device of this multiwindow inter-component communication comprises: acquisition module 51 and release module 52.
Acquisition module 51, for when receiving the first message event of first window, according to described first message event, obtain the triggered target that described first message event is corresponding, and the operational order of described triggered target, described triggered target is at least one assembly of more than one Second Window;
Release module 52, for issuing described operational order to described triggered target, performs operation corresponding to described operational order to make described triggered target.
In a particular application, described device also comprises in Fig. 5 unshowned: the first receiver module 53, memory module 54 and the second receiver module 55.
First receiver module 53, for when first window issues the first message event, receives the first message event of described first window.
Memory module 54, for storing described first message event.
Second receiver module 55, the second message event that the assembly for receiving more than one Second Window is subscribed to.
Above-mentioned first message event or described second message event comprise following at least one:
The event of allocation window attribute, touch-control event, command event.
In an attainable mode, described release module 52, specifically for:
When the assembly obtaining triggered target corresponding to described first message event described more than one Second Window corresponding with subscribing to the second message event is consistent, operational order corresponding to the first message event issued by the assembly to described more than one Second Window.
In order to prevent the communication between window from being paralysed, described device also comprises in Fig. 5 unshowned: window identifier adds module 56.
Window identifier adds module 56, and for adding window identifier for described first window and more than one Second Window, described more than one Second Window subscribes to described second message event by described window identifier,
Described acquisition module 51, specifically for:
When receiving the first message event of first window, obtain the window identifier of triggered target corresponding to described first window;
Described release module 52, specifically for:
Described operational order is issued to the triggered target corresponding with described window identifier according to described window identifier.
After described release module issues described operational order, when described first window or more than one Second Window are closed, the state of the assembly of described first window or more than one Second Window is preserved, during to make the assembly again opening described first window or more than one Second Window, the state of the described first window after display stores or the assembly of more than one Second Window.
Said apparatus and said method are one to one, and the specific example of said method illustrates and is applicable to this device too, and the present invention is not described in detail to the implementation detail of said apparatus.
The embodiment of the invention also discloses:
The device of A1, a kind of multiwindow inter-component communication, comprising:
Acquisition module, for when receiving the first message event of first window, according to described first message event, obtain the triggered target that described first message event is corresponding, and the operational order of described triggered target, described triggered target is at least one assembly of more than one Second Window;
Release module, for issuing described operational order to described triggered target, performs operation corresponding to described operational order to make described triggered target.
A2, device according to A1, described device also comprises:
First receiver module, for when first window issues the first message event, receives the first message event of described first window.
A3, device according to A2, described device also comprises:
Second receiver module, the second message event that the assembly for receiving more than one Second Window is subscribed to;
Described release module, specifically for:
When the assembly of described more than one Second Window corresponding to described triggered target and described second message event is consistent, described operational order issued by the assembly to described more than one Second Window.
A4, device according to A3, described device also comprises:
Window identifier adds module, and for adding window identifier for described first window and more than one Second Window, described more than one Second Window subscribes to described second message event by described window identifier,
And/or,
Described acquisition module, specifically for:
When receiving the first message event of first window, obtain the window identifier of triggered target corresponding to described first window;
Described release module, specifically for:
Described operational order is issued to the triggered target corresponding with described window identifier according to described window identifier.
A5, device according to A1, described device also comprises:
Memory module, for storing described first message event,
Described memory module, specifically for:
After described release module issues described operational order, when described first window or more than one Second Window are closed, the state of the assembly of described first window or more than one Second Window is preserved, when being opened to make the assembly of described first window or more than one Second Window, the end-state that the assembly showing described first window or more than one Second Window is preserved.
A6, device according to any one of A1 to A5, described first message event or described second message event comprise following at least one:
The event of allocation window attribute, touch-control event, command event.
A kind of method of B7, multiwindow inter-component communication, comprising:
When receiving the first message event of first window, according to described first message event, obtain the triggered target that described first message event is corresponding, and the operational order of described triggered target, described triggered target is at least one assembly of more than one Second Window;
Issue described operational order to described triggered target, perform operation corresponding to described operational order to make described triggered target.
B8, method according to B7, described method also comprises:
When first window issues the first message event, receive the first message event of described first window.
B9, method according to B8, described method also comprises:
The second message event that the assembly receiving more than one Second Window is subscribed to;
Correspondingly, issue described operational order to described triggered target, comprising:
When the assembly of described more than one Second Window corresponding to described triggered target and described second message event is consistent, described operational order issued by the assembly to described more than one Second Window.
B10, method according to B9, described method also comprises:
For described first window and more than one Second Window add window identifier, described more than one Second Window subscribes to described second message event by described window identifier,
And/or,
When receiving the first message event of first window, obtain the window identifier of triggered target corresponding to described first window,
Correspondingly, issue described operational order to described triggered target, comprising:
Described operational order is issued to the triggered target corresponding with described window identifier according to described window identifier.
B11, method according to B7, described method also comprises:
Store described first message event,
Accordingly, issuing described operational order to described triggered target, to make after described triggered target performs operation corresponding to described operational order, described method also comprises:
When described first window or more than one Second Window are closed, the state of the assembly of described first window or more than one Second Window is preserved, when being opened to make the assembly of described first window or more than one Second Window, the end-state that the assembly showing described first window or more than one Second Window is preserved.
B12, method according to any one of B7 to B11, described first message event or described second message event comprise following at least one:
The event of allocation window attribute, touch-control event, command event.