Namespace l2dbus.PendingCall

L2DBUS PendingCall

This section describes the PendingCall object which is used to receive messages replies to a request.

A PendingCall object cannot be created directly but instead is returned by a call to the Connection method sendWithReply.

PendingCall

setNotify (pending, notifyFunc, userToken)
cancel (pending)
isCompleted (pending)
stealReply (pending)
block (pending)


PendingCall

setNotify (pending, notifyFunc, userToken)

Sets a notification function for the reply.

This method sets a notification function to be called when the reply is received or the pending call times out.

Parameters:

  • pending userdata The PendingCall object
  • notifyFunc func

    The function to be called when a reply message is received or a timeout occurs. The signature of the notification function should conform to the following:

     function onNotify(pendingCall, userToken)
    
  • userToken optional any An optional user data value passed back to the function.

Returns:

    bool Returns true if notification function is set, false otherwise.
cancel (pending)

Cancels the pending call.

This method drops the pending call such that any reply or error will just be ignored.

Parameters:

  • pending userdata The PendingCall object.
isCompleted (pending)

Checks whether the pending call has received a reply yet or not.

Parameters:

  • pending userdata The PendingCall object.

Returns:

    bool Returns true if a reply has been received and false otherwise.
stealReply (pending)

Tries to get the pending reply.

The method will attempt to get any received reply and if none has been received yet it will return nil. The method can only be called once (assuming a reply message is returned) since ownership of the message transfers to the caller.

Parameters:

  • pending userdata The PendingCall object.

Returns:

    userdata or nil The reply message (if available) or nil.
block (pending)

Block until the pending call is completed.

The blocking call is done as with sendWithReplyAndBlock so the call does not enter the main loop or process other messages while waiting. It simply waits for the reply in question. If the pending call is already completed then the method returns immediately.

Note: When the blocking starts internally the timeout is reset so the the timeout period will extend beyond the time originally specified when the request was made.

Parameters:

  • pending userdata The PendingCall object.
generated by LDoc 1.3