Skip to content

Commit

Permalink
Tell audio playing to run in the background, fork the mapme.at DNS re…
Browse files Browse the repository at this point in the history
…quest, should fix #6
  • Loading branch information
johnmckerrell committed Apr 26, 2018
1 parent fa888c5 commit 03c73ef
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions logcards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def self.door_open_minimum
if min.nil? and LCConfig.config["settings"]
min = LCConfig.config["settings"]["door_open_minimum"]
end
if min.nil?
min = 2
min = min.to_f
if min.nil? || min == 0
min = 0.1
end
min
end
Expand Down Expand Up @@ -332,42 +333,45 @@ def saveUnloggedVisits
puts "#{uid} Arrived"
visits[uid] = { "arrived_at" => time }
if special_sound
cmd = "aplay wav/#{special_sound}"
cmd = "aplay wav/#{special_sound}&"
puts "ringtone: #{cmd}"
blah = `#{cmd}`
elsif user and user["ringtone"]
cmd = "aplay wav/#{user["ringtone"]}"
cmd = "aplay wav/#{user["ringtone"]}&"
puts "ringtone: #{cmd}"
begin
blah = `#{cmd}`
rescue Exception
sleep 4
end
else
blah = `espeak -v en "Thank you, welcome to duss Liverpool #{nickname}" --stdout | aplay`
blah = `espeak -v en "Thank you, welcome to duss Liverpool #{nickname}" --stdout | aplay &`
end
#blah = `aplay thanks-welcome.aiff > /dev/null 2> /dev/null`
end
File.open(VISITS_YAML, "w") do |out|
YAML.dump(visits, out)
end
if door_opened_at
opened_for = ( Time.now - door_opened_at ).to_i
opened_for = ( Time.now - door_opened_at )
while opened_for < LCConfig.door_open_minimum
puts "Sleeping for an extra second"
sleep 1
opened_for += 1
interval = 0.05
puts "Sleeping for an extra #{interval}s"
sleep interval
opened_for += interval
end
setDoorState(0, ssh)
end
if user and user["mapme_at_code"]
puts "Should check into mapme.at"
host = "DoESLiverpool.#{Time.now.to_i}.#{user["mapme_at_code"]}.dns.mapme.at"
Dnsruby::DNS.open {|dns|
puts dns.getresource(host, "TXT")
}
fork do
puts "Should check into mapme.at"
host = "DoESLiverpool.#{Time.now.to_i}.#{user["mapme_at_code"]}.dns.mapme.at"
Dnsruby::DNS.open {|dns|
puts dns.getresource(host, "TXT")
}

#puts `dig DoESLiverpool.#{Time.now.to_i}.#{user["mapme_at_code"]}.dns.mapme.at > /dev/null 2> /dev/null`
#puts `dig DoESLiverpool.#{Time.now.to_i}.#{user["mapme_at_code"]}.dns.mapme.at > /dev/null 2> /dev/null`
end
end
end

Expand Down

0 comments on commit 03c73ef

Please sign in to comment.