A ScriptModule wraps up a class implemented in Carapace script.
ScriptModule allows a class implemented in Carapace script to
be pushed onto a comms stack -- the scripted class
must obey certain rules.
ScriptModule supplies default implementations for the standard
methods so that the scripted class need not provide them all.
The following high-level protocols are implemented in Carapace script:
| Ftp | file transfer protocol |
| Smtp | mail transfer |
| Http | web support |
| Pop3 | message store access |
Click here for an example of a scripted comms module
which can be wrapped up in a ScriptModule.
Given a scripted class which obeys the rules,
a ScriptModule is made using the create function
function. For example, the following creates a ScriptModule to wrap
an Http module:
(create ScriptModule "Http")
The following pushes an Http module onto a stack:
(stack.push (create ScriptModule "Http"))
The Http module can be recovered from the stack
as follows:
(stack.top)
assuming the Http module is at the top of the stack.
A ScriptModule supports only the standard
comms module properties ie.
| property name | property type | description |
|---|---|---|
log |
Log | a log for the communications |
The existence of a property called isBottom on the scripted module
allows the module to be placed at the bottom of a communications
stack.
A ScriptModule supports only the standard
comms module methods ie.
| method name | description |
|---|---|
connect |
connect this module |
receive |
receive data |
receiveInto |
receive data into the supplied buffer |
send |
send data |
disconnect |
disconnect this module |
bind |
bind address information for this module |
listen |
prepare to listen for new connections |
accept |
wait for a new connection to arrive and, if it does, accept it |
For a scripted class to be valid as the basis for a comms module, the following rules must apply:
| name | type |
|---|---|
log |
Log |
stack |
CommsStack |
| name | argument types | return type |
|---|---|---|
connect |
none | empty List () |
send |
Buffer |
Object |
receive |
Integer
|
Object |
receiveInto |
Buffer,
Integer
|
empty List () |
connect |
none | empty List () |
bind |
none | empty List () |
listen |
Integer |
empty List () |
accept |
Integer |
CommsModule |
send method to return a value is
that submission of a message to a message transfer service may result in a
message id being passed back.
receiveInto
method should be supplied in preference to the receive method.
| Contents | Index | Current topic: communications | Related topics: communications classes, objects |