Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Invoking remote object functions – PB Docs 70 – PowerBuilder Library

Invoking remote object functions – PB Docs 70

Invoking remote object functions

Once a connection to a server
application has been established, the client application can begin
using the remote objects provided by the server. The client can
call functions associated with the remote objects and access the objects’ instance
variables.

How to invoke a function

To invoke a function of a remote object, you need to execute
the PowerScript statements required to perform these operations:

  1. Create the remote object.
  2. Invoke a function of the remote object.

note.gif Version 7 proxy objects do not need to be instantiated In PowerBuilder Version 5, you had to include a CREATE statement
to instantiate the proxy object before you could create the corresponding
remote object on the server. In Version 7, you simply create the
remote object directly by calling the CreateInstance function of
the Connection object. The SetConnect function is not supported
for Version 7 proxy objects.

Example

The following script instantiates a remote object on the server
and invokes a function of the remote object:

Creating the object instance

When you deploy a remote object’s class definition
in a client application, the definition on the client has the same
name as the remote object definition deployed in the server application.
This allows for location transparency. Variables
declared with this object type can hold a reference to a local object instance
or a remote object instance. In addition, client-side scripts that
use the object do not need to know where the object was created.

The only time you need to be concerned about the physical
location of the object instance is when you actually create the
object instance. At execution time, you can instantiate the object
locally (by using the CREATE statement) or remotely (by using the
CreateInstance function) depending on your application requirements.
In order to instantiate the object locally, you must have the complete
implementation of the class on the client machine. If you always
plan to instantiate the object remotely, you only need the proxy
object on the client.

This example illustrates location transparency:

Specifying when the function should execute

PowerBuilder supports both synchronous
and asynchronous
function
calls against remote objects. When you issue a synchronous call,
the server executes the function immediately while the client waits
until processing has completed. When you issue an asynchronous call,
the server adds the request to a queue and performs the processing
at a later point in time; meanwhile, the client can continue to
do other work while the server handles the request.

To tell the server when you want the function be executed,
you can specify one of the following keywords in the function call:

  • TRIGGER (the default)
    tells the server that the function call is synchronous
  • POST tells the server that the function call is
    asynchronous

Destroying the object instance

After you’ve finished using a remote object, you
can explicitly destroy the object by using the DESTROY statement,
or you can let PowerBuilder’s garbage collection facility
clear the object out of memory for you automatically:

  • When you issue a DESTROY
    statement against a remote object reference, PowerBuilder destroys
    the remote object and invalidates all remote and local references
    to the object. If a request is made against a remote reference to
    a destroyed object, a NULL object error occurs.
  • When you rely on garbage collection, PowerBuilder
    uses reference counting to determine when the object should be deleted
    from memory. When all client-side references to the remote object
    have been removed, the remote object reference on the client is
    deleted and the server is notified. If there are no other references,
    the object is destroyed when the garbage collector next runs on
    the server.

note.gif Distributed cycles are not detected PowerBuilder can detect unused objects that have circular
references as long as these objects share the same local session;
however, it is unable to detect distributed cycles. Therefore, two
unused objects that point to each other from different sessions
will not be destroyed by the garbage collector.

Making asynchronousfunction calls

When the timing of function
execution is not critical, you can use asynchronous function calls
to improve system throughput. Whereas synchronous
calls
force the client to wait until processing has completed, asynchronous
calls
free the client to do other work while the server handles requests.

How to make an asynchronous call

To make an asynchronous function call, you need to call the
remote object function with the POST keyword.

Example

The following script instantiates a remote object on the server
and makes an asynchronous call to a function of the remote object:

Restrictions

The following restrictions apply to asynchronous function
calls made to remote objects:

  • If the function returns
    a value, the return value will be ignored.
  • The client cannot pass parameters by reference in
    an asynchronous call. Arguments passed by reference will not cause
    errors at compile time, but will result in errors at execution time.
  • The client cannot poll to determine whether an asynchronous
    request has been processed. To notify a client that a request has
    been processed, the server can send a message back to the client.
  • All asynchronous calls are executed in the order
    they are received. However, the exact timing of function execution
    cannot be guaranteed.
  • If the client crashes, execution of queued asynchronous
    or synchronous requests cannot be guaranteed. If the server crashes,
    any queued requests will be lost.

Requesting a message back from the server

Server push

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

Client needs to pass an object reference

To receive a message from the server, the client needs to
pass an object reference to which the server can send messages.
Once the server has the object reference, it 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 session that contains
the object. The server can make both synchronous and asynchronous calls
against the client-side object.

Once the server has a remote reference to work with, it can
use the remote reference just as it would any other object reference.
For example, the server can place the remote reference into an instance
variable so the client does not have to send the object with every
request.

For more information about pushing messages
from the server to the client, see “Pushing messages to the
client”
.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x