Description
The example below illustrates the use of server push technology. The client application makes an asynchronous call to a remote object function. When the server has finished processing, it sends a message back to notify the client that the request has been processed.
Client application window
The client application has a window that allows the user to retrieve some data by issuing a call to a remote object. To initiate the retrieval, the user presses a button that executes the following script:
// Global variable:
// connection myconnect // // Instance variables: // uo_custdata mycustdata // uo_response_object myresponsobject
... myconnect.CreateInstance(mycustdata) myresponseobject = create uo_response_object mycustdata.post process_data(myresponseobject) ...
Note that the call to the remote object function passes a reference to uo_response_object. This is a client-side object that handles messages sent back by the server.
Remote object on the server
The process_data function on the uo_custdata object takes an argument of type uo_response_object. Here is the script for the process_data function:
// Argument:
// uo_response_object respobject // // Perform some processing... ... // Then send a message to the client... respobject.post doneProcessing()
When processing has completed, the server sends an asynchronous request back to the client. The request is added to the client’s request queue.
Response object on the client
The doneProcessing function on the uo_response_object notifies the user that processing has completed:
MessageBox(“Processing finished”,”Your request has completed successfully.”)
|