Connection Object

Top  Previous  Next

The connection object holds the connection to the remote end being controlled. For example an amplifier. It's created by the transport.new function. It automatically tries to reconnect if the connection has dropped and dishes out data in transaction based packets. The TCP Object, SSL Object and Serial Object subclass this object.

Methods

Return

Signature

Description

 

connect()

Connects to the remote end.

 

close()

Disconnect from the remote end.

 

reconnect(timeout)

Disconnects and reconnects to the remote end.

boolean, string

parser( parserType, opt... )

Sets the parser to the type specified. All data in the old parser is transferred over.

transaction

newTransaction( sent, received, timeout )

Create a new transaction with 3 callback functions.

 

send( transaction, boolean )

Queues a transaction.

Connection::connect()

Attempts to establish a connection to the remote end. If successful the connection callback is called on the Connection Object with status parameter "Connected".

Connection::close()

Closes the connection to the remote end. If successful ( if not closed already ) the connection callback is called with the status "Disconnected".

Connection::Reconnect()

Closes and reopens the connection calling the connection callback as appropriate.

Connection::Parser( parserType, opt... )

When data comes in, Girder can chop it into blocks of data before it reaches your code. For example if you know that all responses are delimited by an endline (\n) you can set up a terminated parser with parameter "\n". Each parser has different options. See the parser type page for the details.

Connection::newTransaction( sent, received, timeout )

Creates a new transaction object with the callbacks as specified in the call. The signatures of the callback functions are:

 

Return

Signature

Description

 

sent()

called when data is put on the wire.

ITransactionCallback::Result

received( string )

called when data arrived and was parsed.

ITransactionCallback::Result

timeout( )

called when the transaction times out.

Send( transaction, queueFirst )

Queues the transaction up for sending out. If the connection was not yet established it is simply queued up until the connection is open. If queueFirst is true the transaction is queued at the start of the transaction queue.

Related

Serial Connection

TCP Connection

SSL Connection