Class: CPEE::Frames::SendDataToFrame

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee-frames/implementation.rb

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{NewFrameWait



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/cpee-frames/implementation.rb', line 197

def response
  data_dir = @a[1]
  path = File.join(data_dir,@r.last,'frames.json')
  file = File.read(path)
  data_hash = JSON::parse(file)

  # check if new frame overlaps others if it does, delete overlapped frames
  data_hash["data"].each do | c |
    if CPEE::Frames::target?(c['lx'], c['ly'], c['rx'], c['ry'], @p[1].value.to_i, @p[2].value.to_i, (@p[1].value.to_i + @p[3].value.to_i - 1), (@p[2].value.to_i + @p[4].value.to_i - 1))
      @a[0].send(JSON.dump({ message: 'update', content: { 'callback' => c['callback'], 'data' => @p[5].value.strip == '' ? {} : JSON::parse(@p[5].value) }}))
    end
  end

  nil
end