background image
C H A P T E R 2 3
Endpoint Interface
23-12
Using the Endpoint Interface
Receiving Data Using Input Specs
23
The most common way to receive data is to use input specs. An input spec is a
frame that defines what kind of data you are looking for, termination conditions
that control when the input should be stopped, and callback methods to notify you
when input is stopped or other conditions occur.
An input spec consists of many pieces. It contains slots that define
the type of data expected (
form
slot)
the input target for template and binary data (
target
slot)
the data termination conditions (
termination
slot)
protocol flags for receiving data (
rcvFlags
slot)
an inactivity time-out (
reqTimeout
slot)
the data filter options (
filter
slot)
the options associated with the receive request (
rcvOptions
slot)
a method to be called when the termination conditions are met
(
InputScript
method)
a method to be called periodically to check input as it accumulates
(
PartialScript
method,
partialFrequency
slot)
a method to be called if the input spec terminates unexpectedly
(
CompletionScript
method)
Table 23-2 summarizes the various input data forms and the input spec slots that
are applicable to them. Input spec slots not included in the table apply to all data
forms. For more details on the input spec frame, see "Input Spec Frame"
(page 20-11) in Newton Programmer's Reference.
After you've connected or accepted a connection, you set up your first input spec
by calling
SetInputSpec
. When one input spec terminates, the system
automatically posts another input spec for you when the
InputScript
method
defined in the previous input spec returns. This new input spec duplicates the
one that just terminated. If you don't want this to happen, you can call the
SetInputSpec
method from within the
InputScript
method of your input
spec to change the input spec or terminate the input. Pass
nil
to
SetInputSpec
to terminate the input.
You also use the
SetInputSpec
method if you need to set up an input spec at
some other point. Note that if you want to terminate a current input spec to set up a
new one, you must call the
Cancel
method before calling
SetInputSpec
with
your new spec. (This applies inside an
InputScript
that is called as a result of
calling the
Input
method.)
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна