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

{{{



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/cpee/implementation_callbacks.rb', line 92

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