Class: Channel

mikronode. Channel

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#closeOnDone was set and this was the last channel to
close.

Name Type Description
force boolean

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()

write(data, parameters, writeCallback)

Writes data to the channel

Name Type Description
data string | 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.

parameters object | 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'...}
writeCallback mikronode.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#close or when the channel is closed automatically via
mikronode.Channel#closeOnDone

Properties:
Name Type Description
channel Channel

The channel originating the event

event:done

Emitted when a command has finished successfully.

Properties:
Name Type Description
data string | Array.<string>

The data returned by the channel

channel Channel

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
error error

The error object

channel Channel

The channel originating the event

event:timeout

Emitted when a socket has been idle too long.

Properties:
Name Type Description
message string

'Socket Timeout'

socketStillOpen boolean

If true, communications can continue

channel Channel

The channel originating the event

event:trap

Emitted when a command has failed. Subsequent commands may succeed.

Properties:
Name Type Description
trap mikronode.Trap

The trap object