See a familiar scene that all people experienced now and then: HTTP Cokkies. Web servers can use the Asynchronous Completion Token pattern if they expect responses from Web browsers. For example, a Web server may expect a user to transmit data they filled into a form that was downloaded from the server to the browser in response to a previous HTTP GET request. Due to the sessionless design of the HTTP protocol, and because users need not complete forms immediately, the Web server, acting in the role of a initiator, transmits a cookie(the ACT) to the Web browser along with the form. This cookie allows the server to associate the user's response with his or her original request for the form. Web browsers need not interpret the cookie, but simply return it unchanged to the Web server along with the completed form.
The Asynchronous Completion Token design pattern allows an application to demultiplex and process efficiently the responses of asynchronous operations it invokes on services. Four participants form the structure of the ACT pattern:
Service: A service provides some type of functionality that can be accessed asynchronously.
Initiator: A client initiator invokes operations on a service asynchronously. It also demultiplexes the response returned by these operations to a designated completion handler.
Completion handler: It is a function or object withit an application that is responsible for processing service responses.
ACT: An asynchronous completion token contains information that identifies a particular initiator's completion handler. The initiator passes the ACT to the service when it invokes an operation; the service returns the ACT to the initiator unchanged when the asynchronous operation completes. The initiator then uses this ACT to efficiently demultiplex to the completion handler that processes the response from the original asynchronous operation. Services can hold a collection of ACTs to handle multiple asynchronous operations invoked by initiators simultaneously.
本文解析HTTP异步完成令牌(ACT)模式,通过实际场景介绍如何在无会话设计的HTTP协议中,服务器如何使用ACT模式与浏览器进行异步操作响应处理,以及ACT模式在应用程序中的应用。
32

被折叠的 条评论
为什么被折叠?



