background image
C H A P T E R 2 2
Transport Interface
Using the Transport Interface
22-19
Application Messages
22
Applications can send messages directly to a single transport or to all transports by
using the
TransportNotify
global function. This mechanism serves as a
general way for applications to communicate with transports. Here is an example
of using this function:
TransportNotify('_all,'AppOpened,[appSymbol])
The In/Out Box uses this mechanism to send three different messages to transports:
AppOpened
,
AppClosed
, and
AppInFront
. The
AppOpened
message notifies
the transport that an application has opened and is interested in data from the
transport. The In/Out Box sends this message to all transports when it opens. This
method is not defined by default in
protoTransport
since it's transport-specific.
If you want to respond to the
AppOpened
message, you must define this method in
your transport.
This message is designed to support applications that might poll for data, such as a
pager. For example, when the application is open, it can notify the transport with
this message so that the transport can poll more frequently (and use more power)
than when the application is closed. Another use might be for an application to
notify a transport that automatically makes a connection whenever the application
is open.
The
AppClosed
message notifies the transport that an application has closed. The
In/Out Box sends this message to all transports when it closes. Again, this method
is not defined by default in
protoTransport
since there is no default action--
it's transport-specific. If you want to respond to the
AppClosed
message, you
must define this method in your transport.
Note that more than one application can be open at a time in the system. If you
want your transport to do something like disconnect when it receives this message,
keep track of how many times it's received the
AppOpened
message and don't
actually disconnect until it receives the same number of
AppClosed
messages.
The
AppInFront
message notifies the transport of a change in the frontmost
status of an application--either the application is no longer frontmost, or it now is.
The In/Out Box sends this message to all transports when another application is
opened in front of the In/Out Box view, or when the In/Out Box view is brought to
the front. Note that the
AppInFront
message is not sent when an application is
opened or closed, so you need to check for the
AppOpened
and
AppClosed
messages to catch those occurrences.
Again, this method is not defined by default in
protoTransport
since there is
no default action--it's transport-specific. If you want to respond to the
AppInFront
message, you must define this method in your transport. Not that this method is
used only in special circumstances and is not needed by most transports.
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна