Studio:AutoScript Messages

From STRIDE Wiki
Revision as of 21:59, 9 July 2008 by Chrisj (talk | contribs)
Jump to navigation Jump to search

STRIDE offers many types of messaging as well as many options on messaging. To ease your understanding, this section describes overall concepts and then describes the precise functionality that STRIDE provides.

Messaging Concepts

Origin and Directioning

STRIDE has the concept of a message owner and a message user. In general STRIDE usage, the Owner and User imply target and host, but for messaging this meaning is transparent.

Message User

A message user may be any script that is not registered as the owner.

Message Owner

The message owner is a script that has successfully registered itself as the owner of the message (by calling the Register method). A message may only have one registered owner.

Message Override Owner

The message override owner of a message is the script that successfully registered as the override owner (by calling the RegisterOverride method).

Synchronous / Asynchronous Messaging

Messages that are sent between a message owner and a message user may asynchronous or synchronous.

Asynchronous Messaging

An asynchronous message is also known as a "non-blocking" message. A message transfers between message owner and message user. If the message user is initiating a message, the message is sent to the message owner and the message user continues processing. If the message owner is sending a response message the message is sent to the message user and the message owner continues processing. In either case an asynchronous message enqueues an event to the receiver's script queue and continues processing. The initiator was not blocked from continuing processing.

Synchronous Messaging

A synchronous message is also known as a "blocking" message. A message transfers between message owner and message user. If the message user is initiating the message, the message is sent to the message owner and the message user waits until it receives a response. If the message owner is initiating the message, it too is blocked until it receives a response from the message user.

Messaging Types

Broadcast Messages

One-Way Command Messages

One-Way Response Messages

Two-Way Command/Response Messages

Bypass Override

Broadcast Messaging

Broadcast messaging is used to have a message owner broadcast messages. A message user will subscribe to a message for a time. The message user will receive messages until the message user's script exits or until it unsubscribes from the message. The exact process for how this is achieved is as follows:

1. A Message User calls Subscribe() to register that it is interested in receiving message events from a given message.
2. When the Message Owner calls Broadcast(), a message event is sent to all Subscribers of the message. The message event received by the Message User is enqueued to its script's event queue. The Message User may then evaluate the messages it has received by making calls to WaitForEvent().
3. When a Message User no longer wishes to receive message events from a given message, it will call Unsubscribe() to unregister its interest in receiving events.

For a broadcast message (a message whose ascript.Messages.Item().Type is "BroadcastMessage"):

  • Its owner (ascript.Messages.Item().Owner) will have a Broadcast method.
  • Its user object (ascript.Messages.Item().User) will have a Subscribe method and an Unsubscribe method.
  • These are the only methods available for this message type. Thus other message methods (e.g. Register/Unregister) will not be available.

Command/Response Messaging

The other form of messaging provided by STRIDE involves direct messaging between a message owner and message user. There are three types of direct messaging between a message owner and message user and they depend upon what information is being passed in which direction.

Message Type
Meaning
One-Way Command Messaging The message user will only send a command payload to the message owner. The message user will not receive any information back from the message owner.
One-Way Response Messaging The message user will only receive a response payload from the message owner. The message owner will not receive any information from the message user.
Two-Way Command/Response Messaging The message user will send a command payload from the message owner AND it will receive a response payload as part of the messaging.

One-Way Command Messaging

One-Way Response Messaging

Two-Way Command/Response Messaging