Module: NominetEPP::Operations::Poll

Included in:
Client
Defined in:
lib/nominet-epp/operations/poll.rb

Overview

EPP Poll Operation

Defined Under Namespace

Classes: AckError

Instance Method Summary collapse

Instance Method Details

#ack(msgID) ⇒ Boolean

Acknowledges a polled message ID

Parameters:

  • msgID (String)

    Message ID to acknowledge

Returns:

  • (Boolean)

    ack successful



47
48
49
50
51
52
53
54
# File 'lib/nominet-epp/operations/poll.rb', line 47

def ack(msgID)
  resp = @client.poll do |poll|
    poll['op'] = 'ack'
    poll['msgID'] = msgID
  end

  return resp.success?
end

#poll {|data| ... } ⇒ nil, Array<String,XML::Node>

Poll the EPP server for events.

If a block is given then it will be invoked once for each pending event. If no block is given the only the first received event will be returned along with the message ID of the event to allow the message to be ack’d. nil is returned if there is an error in the response or if there are not further messages to process.

Examples:

Without a block

msgID, xml = client.poll
... process xml ...
client.ack(msgID)

With a block

client.poll do |xml|
  ... process xml ...
end

Yields:

  • (data)

    process data if messages to poll

Yield Parameters:

  • data (XML::Node)

    Response data

Returns:

  • (nil)

    no messages to handle

  • (Array<String,XML::Node>)

    message ID and response xml data

Raises:

  • (AckError)

    ack of event notification failed

See Also:



33
34
35
36
37
38
39
40
41
# File 'lib/nominet-epp/operations/poll.rb', line 33

def poll
  while resp = poll_req
    return if resp.code != 1301 || resp.msgQ['count'] == '0'
    return [resp.msgQ['id'], resp.data] unless block_given?

    yield resp.data
    raise AckError, "failed to acknowledge message #{resp.msgQ['id']}" unless ack(resp.msgQ['id'])
  end
end