Top  | Previous | Next

system.util.sendMessage

Description

This function sends a message to clients running under the Gateway, or to a project within the Gateway itself. To handle received messages, you must set up event script message handlers within a project. These message handlers run Jython code when a message is received. You can add message handlers under the "Message" section of the client/Gateway event script configuration dialogs.

 

Note that messages cannot received within a Designer. However, messages can be sent within the Designer in a script (assuming that read/write comm is enabled).

 

information2 This function accepts keyword-style invocation. See also: Functions / Keyword Invocation

Syntax

system.util.sendMessage(project, messageHandler, payload, scope, clientSessionId, user, hasRole, hostName)

Parameters

String project - The name of the project containing the message handler.

String messageHandler - The name of the message handler that will fire upon receiving a message.

PyDictionary payload - Optional. A PyDictionary which will get passed to the message handler. Use "messagePayload" in the message handler to access dictionary variables.

String scope - Optional. Limits the scope of the message delivery to "C" (clients), "G" (Gateway), or "CG" for clients and the Gateway. Defaults to "C" if the user name, role or host name parameters are set, and to "CG" if none of these parameters are set.

String clientSessionId - Optional. Limits the message delivery to a client with the specified session ID.

String user - Optional. Limits the message delivery to clients where the specified user has logged in.

String hasRole - Optional. Limits the message delivery to any client where the logged in user has the specified user role.

String hostName - Optional. Limits the message delivery to the client that has the specified network host name.

Returns

List - A List of Strings containing information about each system that was selected for delivery, where each List item is comma-delimited.

Scope

All

Examples

Example 1 (simple message to both Client and Gateway handlers)

 

project="X"

 

# It's important that both Gateway and Client versions of this message handler 

# have been created

messageHandler="myMessageHandler"

 

scope="CG"

myDict = {'first': "Hello", 'second': "World"}

 

results=system.util.sendMessage(project,messageHandler,myDict)

 

Assuming that there is one local client running project X, the results List will contain these Strings:

type=Gateway,project=X,messageHandler=testHandler,filterParams={hostName=, 

clientSessionId=, scope=CG, user=, hasRole=},sendStatus=SENT

 

type=Client,sessionId=65F7A472,clientAddress=127.0.0.1,clientHostName=127.0.0.1,

project=X,messageHandler=testHandler,filterParams={hostName=, clientSessionId=, 

scope=CG, user=, hasRole=},sendStatus=SENT

 

Example 2 (message to client handlers only where a specified user is logged in)

system.util.sendMessage(project="X",messageHandler="myMessageHandler",scope="C",

user="Bob")