Blue Mango Learning Systems GLX Application Framework version 1.2.0 build 1

Printer friendly version

command glxapp_publishBroadcast

Publishes a message that an object or variable wants to announce as being broadcast.

command glxapp_publishBroadcast pObject, pBroadcastType, pDefaultMessage
Parameters
TypeNameDescription
Simple parameter. pObject A reference to an object (or "global") that will be publishing the broadcast.
Simple parameter. pBroadcastType A string identifying the type of broadcast. This helps categorize messages that are sent.
Simple parameter. pDefaultMessage The default message that is sent to any object that registers to listen for broadcasts of this type using glxapp_listenForBroadcast. This message will be sent unless you override it when calling glxapp_listenForBroadcast.
Description

When an object publishes a broadcast custom properties are stored in it so that other objects can interrogate it and sign up to listen for that broadcast. Publishing the broadcast won't actually send the broadcast however. You still have to call glxapp_broadcast to perform the actual broadcast.

There are two approaches when defining the type of broadcasts that you send. You can be very specific in defining the type or very general.

An example of defining your broadcast type specificly would be:

put "tag name updated" into theBroadcastType 
glxapp_publishBroadcast theObject, theType, theMessage

The type is specific enough that the object the broadcast is sent to knows that the tag name was updated.

An example of defining your broadcast type generally would be:
put "tag" into theBroadcastType 
glxapp_publishBroadcast theObject, theType, theMessage

In this example the type is not specific enough to tell you what actually happened to a "tag". Was the name updated? Was it created? Deleted? In this case you specify the event type when you broadcast the message. An example:

put "tag name changed" into theParamsA["event type"] 
put 12 into theParamsA["id"]
glxapp_broadcast theObject, "tag", theParamsA

The object the broadcast is sent to can use the "event type" array key to determine what happened to the tag.

One advantage of defining types generally is that objects interested in the broadcast only have to register for one type of broadcast. If you define the broadcast type more specificly then objects may have to register for many different broadcasts (i.e. an object is interested in all events related to "tags"). This may be desirable in some cases however.

Return

Empty

See also