background image
C H A P T E R 2 3
Endpoint Interface
Using the Endpoint Interface
23-19
Handling Unexpected Completion
23
The
CompletionScript
message is sent to the input spec frame when the input
spec completes unexpectedly--for example, because of a time-out expiring or a
Cancel
message.
If you do not specify a
CompletionScript
method in your input spec frame, an
exception is forwarded to the endpoint
ExceptionHandler
method.
Special Considerations
23
If you want to set up an input spec, but you never want to terminate the input, you
can set up the input form to be either
'string
or
'bytes
data, and not define
any of the data termination conditions. In this case, it is up to you to read and flush
the input. You can do this by using a
PartialScript
method that calls the
FlushPartial
method at the appropriate times. Note that if the input exceeds
the
discardAfter
size, the oldest data in the buffer is deleted to reduce the size
of the input.
Alternatively, if you omit the
InputScript
method, yet define the input data
form and termination conditions, the input continues to be terminated and flushed
at the appropriate times. The only difference is that without an
InputScript
method, you'll never see the complete input.
Receiving Data Using Alternative Methods
23
The methods described in this section allow you to receive data in ways other than
letting an input spec terminate normally. You may not need to use these methods;
they're provided for flexibility in handling special situations.
You can force the system to send a pending input spec the
InputScript
message
by calling the
Input
method. Note that this method is appropriate to use only
when receiving data of the forms
'string
and
'bytes
. Also, in an
InputScript
method that is called as a result of calling
Input
, you cannot use
SetInputSpec
to change or terminate the input spec. Instead, you must first send the
Cancel
message to cancel the current input spec.
You can look at incoming data outside the scope of your
InputScript
or
PartialScript
method by calling the method
Partial
. This method returns
data from the input buffer but doesn't remove it from the buffer. You can use this
method to sample incoming data without affecting the normal operation of your
input spec and its callback methods. Note that this method is appropriate to use
only when receiving data of the forms
'string
and
'bytes
.
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна