Method based on the client-server persistent session of user session pattern
Technical field
The present invention relates to a kind of method of the client-server persistent session based on the user session pattern.
Background technology
In the cloud computing epoch; Computer software is to install and operate in the cloud center; The user can be anywhere, whenever, only need a client or web browser just can run on the supercentral software application of cloud, the very big convenience of use software application is provided to the user like this; The user can pass through any one computer, uses a software program through network.But a greatest weakness of cloud computing is the dependence to the Internet.If during the user uses cloud service; Incidents such as occurring network interruption; The user not only has no idea continue to use cloud service, and ongoing stage of working result also might lose, and this is because network interrupts causing subscription client and cloud central server " dialogue " interruption.The situation that this " dialogue " interrupted also possibly occur in the user because there is urgent thing to handle, and has little time the work in the normal termination hand, and perhaps the user has surpassed expection at time of leaving the work client; Say further that again a user also might need the conversion work place in the process of using cloud service.Such as, after coming home from work, continue him on the computer of staying at home in the work that office does not have completion, perhaps need change in another office and ongoing work is discussed together with the colleague.Under existing technology, the user before leaving office, at first to finish he at that time with " dialogue " at cloud computing center, behind another place, rebulid a new dialogue more then, this has just brought very big trouble to the user.Except needs are closed and rebuild the dialogue, after getting into new dialogue, the user need rebulid operational environment at that time, sometimes, this process expensive time of meeting, brings great inconvenience to the user, even possibly cause economic loss.
Summary of the invention
The object of the invention promptly is to overcome the deficiency of prior art; A kind of method of the client-server persistent session based on the user session pattern is provided, has fundamentally solved " dialogue " and interrupted this problem, allow the user at any time; Continue " dialogue " of original and Cloud Server on the different client side; The user does not need special " dialogue " that finishes at that time, when using new client when leaving a client; Can continue original " dialogue " immediately; And do not need to rebuild, guarantee that the work that the user accomplished at that time can not lose, guarantee the user can be again in any client, whenever recover no matter because any former thereby the client of interrupting and the advantages such as " dialogues " of online service device.
The objective of the invention is to realize: based on the method for the client-server persistent session of user session pattern through following technical scheme; Guarantee that the cloud computing service is after server, client computer or communication network failure are repaired; After perhaps the client user changes the work-yard; Can return to the preceding scene of service disruption, it may further comprise the steps:
(1) login: when the user signs in to a network service; Server " user session " mechanism is the inquiring user dialog database at first; Check " user session " that whether this user suspends; If " user session " that this user does not suspend; Then " user session " mechanism is created new " user session " for this user, if this user has time-out " user session ", then " user session " mechanism reads this user all " user session " and related data thereof and is presented on the interface from the user session database;
(2) " user session " activity: the user can select to continue " user session " of any one time-out; Also can select to begin new " user session "; If " user session " that the user selects to continue to suspend; Then " user session " mechanism is recovered corresponding dialogue data from the user session database, and the user continues original work;
(3) " user session " suspends: when the user asks to suspend one " user session ", perhaps " dialogue " when closing to an end, " user session " mechanism " dialogue " machine-processed storage of not storing in the user session database;
(4) " user session " accomplished: when the user asked to finish one " user session ", " user session " mechanism discharged the system resource of its use, and from the user session database, deleted relevant " dialogue " data.
Described " user session " comprise the user in a period of time through client and server carry out once or the exchanges data once;
Described " user session " suspends " dialogue " that comprise client user's active request and suspends, and " dialogue " that server breaks off suspends, and " dialogue " that server, client computer or communication line fault cause suspends.
The invention has the beneficial effects as follows:
(1) the present invention provides a kind of method of the client-server persistent session based on the user session pattern; In general, fundamentally solved " dialogue " and interrupted this problem, allowed the user at any time; Continue " dialogue " of original and Cloud Server on the different client side; The user does not need special " dialogue " that finishes at that time, when using new client when leaving a client; Can continue original " dialogue " immediately; And do not need to rebuild, guarantee that the work that the user accomplished at that time can not lose, guarantee the user can be again in any client, whenever recover no matter because any former thereby the client of interrupting and " dialogue " of online service device;
(2) the present invention provides a kind of method of the client-server persistent session based on the user session pattern; Specifically; All bring benefit for network/cloud application developer and user; The user that network/cloud is used can suspend their work, at any time all can continue original work through any one client, prevents because special circumstances such as network failure cause the user job that the client and server interchange is interrupted bringing to lose;
(3) the present invention provides a kind of method of the client-server persistent session based on the user session pattern, the user's that network/cloud is used benefit:
A. bring great mobility to the user, they can bring into use network/cloud service to carry out a job in any one place, if necessary, can move to the original work of other local continuation;
B. improve user's operating efficiency, user's login system will present to the user to his state of last task, the work that will begin in a minute, and do not need to go again to create the operational environment of last time;
C. the work that guarantees the user is not lost; The not free work of preserving oneself even the user makes off because of emergency; When perhaps having caused the user not exchange with network/cloud service because of external cause; The present invention can store the operational data that the user has carried out but also do not preserve, and makes the user when logining next time, can continue original work;
D. not free restriction, the user does not worry because overtime and obliterated data;
E. a user can have a plurality of " user sessions " to exist simultaneously, and the user can switch to another work from a job easily;
(4) the present invention provides a kind of method of the client-server persistent session based on the user session pattern, to the benefit of network/cloud application developer:
A. make network/cloud application can store " user session " data very easily and not need the developer to do any extra work;
B. the transparency that realizes, the developer can programme according to the mode of original processing " dialogue ";
C. scheme provided by the invention can be applied to any network/cloud system;
D. improve developer's operating efficiency, do not need the developer to handle the task of " user session ", they can be placed on energy in the exploitation of professional task fully.
Description of drawings
Fig. 1 is a flow chart of the present invention;
Fig. 2 is " user session " of the present invention state diagram;
Fig. 3 is " user session " of the present invention datagram;
Fig. 4 is the present invention's's " user session " realization flow figure;
Fig. 5 is that the present invention's " user session " module asks to carry out the preposition and rearmounted realization flow figure that realizes " user session " action required that handles to HTTP.
Embodiment
Below in conjunction with accompanying drawing the present invention is done further description, but protection scope of the present invention is not limited to the following stated.
As shown in Figure 1; Based on the method for the client-server persistent session of user session pattern, guarantee that the cloud computing service is after server, client computer or communication network failure are repaired, after perhaps the client user changes the work-yard; Can return to the preceding scene of service disruption, it may further comprise the steps:
(1) login: when the user signs in to a network service; Server " user session " mechanism is the inquiring user dialog database at first; Check " user session " that whether this user suspends; If " user session " that this user does not suspend; Then " user session " mechanism is created new " user session " for this user, if this user has time-out " user session ", then " user session " mechanism reads this user all " user session " and related data thereof and is presented on the interface from the user session database;
(2) " user session " activity: the user can select to continue " user session " of any one time-out; Also can select to begin new " user session "; If " user session " that the user selects to continue to suspend; Then " user session " mechanism is recovered corresponding dialogue data from the user session database, and the user continues original work;
(3) " user session " suspends: when the user asks to suspend one " user session ", perhaps " dialogue " when closing to an end, " user session " mechanism " dialogue " machine-processed storage of not storing in the user session database;
(4) " user session " accomplished: when the user asked to finish one " user session ", " user session " mechanism discharged the system resource of its use, and from the user session database, deleted relevant " dialogue " data.
Described " user session " comprise the user in a period of time through client and server carry out once or the exchanges data once;
Described " user session " suspends " dialogue " that comprise client user's active request and suspends, and " dialogue " that server breaks off suspends, and " dialogue " that server, client computer or communication line fault cause suspends;
Described " user session " can be embodied directly in the webserver, also can be implemented in earlier in the software module, inserts it in existing webserver again.
Present computer " dialogue " is meant a series of interchange that a user carries out through a client and a server in a period of time; And the time of this " dialogue " beginning all is that the user clearly asks; And time that finishes or propose by the user; Also might be that server is because a variety of causes finishes (such as the user does not exchange for a long time) by force.
As shown in Figure 2, the present invention introduces new ideas that are called " user session ", and " user session " is meant a series of interchange that a user carries out through client and server in a period of time.Can find out that from definition " user session " is that with the essential difference of " dialogue " " user session " allows the user to exchange with given server through different clients.Roughly, " user session " is made up of a plurality of " dialogues ", and the end of " user session " is to be confirmed by the user fully.One " user session " can reside in any one state in following three states: activity, time-out, completion; During one " user session " beginning is to reside in " activity " state; " user session " of an activity is always corresponding with one " dialogue ", and in this " dialogue " no matter because any former thereby finish the back and get into halted state, after the user finishes one " user session "; It will get into completion status; According to the management policy of formulating, the keeper also has the right to become completion status to one " user session " from halted state, when the user reuses " user session " of a time-out; It has just got into active state again, and one " user session " can be changed inferior arbitrarily between " time-out " and " activity " state.
As shown in Figure 3; Mission critical of realization " user session " mechanism is wanted to safeguard all data relevant with " user session " exactly; Become " completion " state up to it; When " user session " when being in active state, the data relevant with it realize that the mechanism of " dialogue " can preserve.But when " user session " state becomes time-out from activity, " dialogue " mechanism will no longer be preserved relevant data.This is that " dialogue " finishes because to " dialogue " mechanism, so " user session " mechanism during this time must be born and safeguard relevant data.When later user was connected to " user session " again, the data that " user session " mechanism needs to recover relevant were given " dialogue " mechanism, do not lose with the work of guaranteeing the user.
The present invention can expand the present webserver with several kinds of ways; Realize the function of " user session "; Such as; Webserver developer can be embodied directly in the function of " user session " in the webserver, also can be implemented in " user session " in the software module and insert it again in the existing webserver then.Although the employed webserver is different in the different computer platforms, realize that on them the software pattern of " user session " is identical.The present invention adopts distinct methods to realize that the crucial difference of " user session " is: where expands aforesaid operations; Such as; We promptly can be attached to aforesaid operations in the event processing module of HPPT Modules of ASP.NET; Also can add event processing module to these operations to the HPPT Handlers of ASP.NET; Although our method that is to use HTTP Module described herein, this implementation method also is applicable to other implementation method, and protection scope of the present invention is not limited to the above.
Like Fig. 4, shown in Figure 5; ASP.NET allows the developer to expand its function through adding HTTP Module; In order to realize " user session "; We have realized a HTTP Module and have joined the flow process of HTTP Runtime to it that " user session " module can be carried out preposition and rearmounted processing to the HTTP request and realized " user session " necessary operations.
Each " user session " provides at least two event handlers; Two event handlers are handled two HttpApplication incidents respectively, and described two HttpApplication incidents comprise Application_OnPreRequestHandleExecute and Application_OnPostRequestHandlerExecute;
Described Application_OnPreRequestHandleExecute pre-process http request; Confirm whether need continue or restart one " user session "; Concrete comprises: if this request not corresponding " user session "; Then transfer to " user session " page; Upload " user session " that the user selects or create new " user session ", and set up " user session " object, if this request has accordingly " user session " then is left intact;
Described Application_OnPostRequestHandlerExecute asks to carry out postposition to http and handles; Confirm whether the user asks to finish or suspend one " user session "; And take corresponding step, concrete comprises: if " user session " is in active state, then write the user session database to relevant " dialogue " data; If " user session " is in halted state; Then change " dialogue " state in the user session database,, then clear up " dialogue " data if " user session " is in completion status;
Total method, attribute and the incident of all application objects in the described HttpApplication definition ASP.NET application program.