Pushing messages to the client – PB Docs 70

Pushing messages to the client

Server push

Using a technique called server push,
the server can send messages to the client. This is particularly
useful when the client needs to be notified of the completion of
an asynchronous request.

Requests are queued

The server can make both synchronous and asynchronous calls
against client-side objects. The client handles server-side requests
in the same way that the server handles client-side requests. Asynchronous
requests against a particular client-side object are queued and
processed after all synchronous requests.

Client needs to pass an object reference

To send a message to the client, the server needs to know
which client-side object to send the message to. Therefore, the
client must pass a reference to a nonvisual object to the server.
When the server receives the object reference, it automatically
creates a remote reference to the client-side object and calls one or
more functions associated with this object. Function calls made
against the remote reference are passed back over the wire to the
client that contains the object.

To ensure that messages are actually sent to the client-side
object, the client must not pass an autoinstantiated object to the
server. Instead, the client must pass a reference to an object that
is created with the CREATE statement.

What the server can do with remote references

PowerBuilder allows the server to use a remote reference just
as it would any other object reference. Once the server has a remote
reference to work with, it can place the remote reference into an
instance variable so the client does not have to send the object
reference with every request. In addition, the server can pass the
object reference to and from shared object sessions.


This example 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

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:

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:

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x