class Wamp::Client::Request::Call

Public Instance Methods

cancel(request_id, mode='skip') click to toggle source

Method specific to this request that will cancel it

# File lib/wamp/client/request/call.rb, line 32
def cancel(request_id, mode='skip')

  # If the request is still in flight
  if self.requests[request_id]
    # Create the message
    message = Message::Cancel.new(request_id, { mode: mode })

    # Send it
    send_message(message)
  end

end
create_request(request_id, procedure, args=nil, kwargs=nil, options={}, &callback) click to toggle source
# File lib/wamp/client/request/call.rb, line 45
def create_request(request_id, procedure, args=nil, kwargs=nil, options={}, &callback)

  # Create the lookup
  lookup = {p: procedure, a: args, k: kwargs, o: options, c: callback}

  # Create the message
  message = Message::Call.new(request_id, options, procedure, args, kwargs)

  # Return
  [lookup, message]
end
process_error(message, lookup) click to toggle source
# File lib/wamp/client/request/call.rb, line 89
def process_error(message, lookup)
  if lookup
    # Get the params
    procedure = lookup[:p]
    callback = lookup[:c]

    # Create the details
    details = message.details || {}
    details[:procedure] = procedure unless details[:procedure]
    details[:type] = 'call'

    # Return the values
    [callback, details]
  else
    [nil, nil]
  end
end
process_success(message, lookup) click to toggle source
# File lib/wamp/client/request/call.rb, line 57
def process_success(message, lookup)
  if lookup
    # Get the params
    procedure = lookup[:p]
    options = lookup[:o] || {}
    callback = lookup[:c]

    # Create the details
    details = message.details || {}
    details[:procedure] = procedure unless details[:procedure]
    details[:type] = 'call'

    # Set the should keep flag if this is a progress message
    should_keep = details[:progress]

    # Only return the information if not progress or receive progress is true
    if not details[:progress] or (details[:progress] and options[:receive_progress])

      # Create the response
      result = Response::CallResult.from_yield_message(message)

      # Return the values
      [callback, result.to_hash, details, should_keep]

    else
      [nil, nil, nil, should_keep]
    end
  else
    [nil, nil, nil]
  end
end