OpenAjaxPublishAsync

  

DEVELOPER

OpenAjaxPublishAsync

 

 

Purpose

.OpenAjaxPublishAsync Client method publishes messages to the OpenAjax HubOpenAjax Hub (The OpenAjax Alliance describes the OpenAjax Hub as the following: "The OpenAjax Hub is a set of standard JavaScript functionality defined by the OpenAjax Alliance that addresses key interoperability issues that arise when multiple Ajax libraries are used within the same web page." Copyright 2007-2008 OpenAjax Alliance  'OpenAjax Hub 1.0 Specification' OpenAjax Alliance Wiki, 14 December 2009. Web. 29 February 2012.) in the Open Client browser. Subscribers to the message as defined in the $topic parameter receive the message payload as contained in the $data parameter. If the kernel tries to call the method when connected to an older Open Client, a rollback run-time error occurs and the current function terminates.

Note: When using the OpenAjaxPublishAsync Client method, the kernel does not wait for a response from the method before continuing and no value is returned.

Click here for more information about the OpenAjax Hub.

Object Type

Client

Syntax

Client.OpenAjaxPublishAsync ($topic, $data)

Operation

$topic defines a message in the OpenAjax Hub.

$data contains the message payload that is sent to subscribers of the $topic parameter in the hub. The maximum payload length is 2000 bytes.

Remarks

If using this feature, it is recommended that the TP_ROLLBACK setting is set to 'Y' in the pro4v[n].ini file.

Example

The following is an example that OpenAjaxPublishAsync method:

$topic = “Weather�?

$data = "{'town': 'Luton', 'TempMin': '4C',  'TempMax':'11C', 'Outlook':'Rain & Wind', 'WindSpeedMax':'35mph', 'Tomorrow': 'Sunny'}"

 

Client.OpenAjaxPublishAsync($topic, $data)

 

The html document below shows the contents of a Template page (the Template page defined in an Open Client Session Definition) that subscribe to and handle the published event from the logic example.

Example Template Page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

</head>

<body>

<div id="proiv_panel">

</div>

<script language="javascript">

OpenAjax.hub.subscribe("Weather ", function(event, obj){         obj.returnValue = "Weather received.�?      });

</script>

</body>

</html>

 

Note that the 'async' handler javascript does not set any value in the returnValue property of the passed in 'obj'.

 

Note: This method applies to PROIV Open Client only.


 

Comment on this topic

Topic ID: 510172