Class: CPEE::Callbacks::ExCallback

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee/implementation_callbacks.rb

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cpee/implementation_callbacks.rb', line 32

def response
  id = @a[0]
  opts = @a[1]
  callback = @r[-1]

  if opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'callback'
    ret = {}
    ret['values'] = @p.map{ |e|
      [e.name, e.class == Riddl::Parameter::Simple ? [:simple,e.value] : [:complex,e.mimetype,e.value.path] ]
    }
    ret['headers'] =  @h

    CPEE::Message::send(
      :'callback-response',
      callback,
      opts[:url],
      id,
      {},
      {},
      ret,
      opts[:redis]
    )
  elsif opts[:redis].get("instance:#{id}/callback/#{callback}/type") == 'vote'
    if @p.length == 1 && @p[0].name == 'continue' && @p[0].class == Riddl::Parameter::Simple
      CPEE::Message::send(
        :'vote-response',
        callback,
        opts[:url],
        id,
        {},
        {},
        @p[0].value,
        opts[:redis]
      )
    else
      @status = 400
    end
  else
    @status = 503
  end
  nil
end