You are here: Lua Scripting Resources eGuide > Lua Scripting API Reference Guide > ASI Library > setWriteListener

21.7.7 setWriteListener

self = port:setWriteListener(writeCallback[, object])

Registers a callback for write-complete notifications. The callback is called after a write request. Returns self.

Parameter

Type

Description

port

in port object

The port to modify.

writeCallback

in function

Callback to receive write-complete notifications.

object

in any (optional)

If an object is provided, it will be passed as the first parameter to the specified callback function. The object can be of any type except nil.

self

out port object

The input port is returned as the output.

Introduced in platform.apiLevel = '2.7'.

Callback Function

writeCallback([object , ]port[, error])

This callback is called when a write request has been completed. A string is passed in case an error occurred while processing the write request.

Parameter

Type

Description

object

in any (optional)

If an object was provided as a parameter to the function setWriteListener, it will be passed as the first parameter to this callback function.

port

in port object

The port where the data was sent to be written.

error

in string (optional)

An error message if an error occurred while processing the write request; nil otherwise.