new mikronode.Channel(id, conn)
Channel (should not be instantiated directly)
| Name | Type | Description |
|---|---|---|
id |
number | |
conn |
mikronode.Connection |
Fires:
Members
-
clearEventsboolean
-
Clear event listeners on done
-
readonlyclosedboolean
-
-
closeOnDoneboolean
-
Close channel on done
-
readonlyclosingboolean
-
-
readonlyidnumber
-
Channel ID
-
readonlylastCommandArray.<string>
-
-
readonlyrunningboolean
-
-
saveBufferboolean
-
Save each line received in a buffer and pass the entire buffer to the done event.
Otherwise the done event will not get all the lines, only the last line. This is
handy when following trailing output from a listen command, where the data could
be endless.
Methods
-
close(force)
-
Closes the channel This will close the connection if
mikronode.Connection#closeOnDonewas set and this was the last channel to
close.Name Type Description forceboolean Force close even of there are other commands pending.
Otherwise mark the channel as 'closing' which will prevent new commands
from being started but will let queued ones finish. -
finalize()
-
Calls
mikronode.Channel#close(false) -
write(data, parameters, writeCallback)
-
Writes data to the channel
Name Type Description datastring | Array.<string> Can be a single string with the command and
optional parameters separated by '\n' or an array of strings with the
command in the first position and the parameters in the rest.parametersobject | Array.<string> optional If the first parameter is a command
string, this object will be treated as the parameters for the command.
It can be an array or strings...['name=value','name=value'...]
or an Object...
{'name': 'value', 'name': 'value'...}writeCallbackmikronode.Channel.writeCallback optional This will be called just
before write actually writes the data to the connection.
Type Definitions
-
mikronode.Channel.writeCallback()
-
writeCallback
Type Description Channel
Events
-
event:close
-
Emitted when the channel is closed either by an explicit call to
mikronode.Channel#closeor when the channel is closed automatically viamikronode.Channel#closeOnDoneProperties:
Name Type Description channelChannel The channel originating the event
-
event:done
-
Emitted when a command has finished successfully.
Properties:
Name Type Description datastring | Array.<string> The data returned by the channel
channelChannel The channel originating the event Fatal event.
-
event:error
-
Emitted when a non-recoverable error has occurred on the socket. No further commands
can be processed on any channel.Properties:
Name Type Description errorerror The error object
channelChannel The channel originating the event
-
event:timeout
-
Emitted when a socket has been idle too long.
Properties:
Name Type Description messagestring 'Socket Timeout'
socketStillOpenboolean If true, communications can continue
channelChannel The channel originating the event
-
event:trap
-
Emitted when a command has failed. Subsequent commands may succeed.
Properties:
Name Type Description trapmikronode.Trap The trap object