Still not working, trying to use Gio async stuff
This commit is contained in:
@@ -1,23 +1,27 @@
|
|||||||
module Wince::Location
|
module Wince::Location
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
@@channel = Channel(Geoclue::Simple).new(1)
|
|
||||||
@@client : Geoclue::Simple? = nil
|
@@client : Geoclue::Simple? = nil
|
||||||
@@fiber : Fiber = spawn setup_client
|
|
||||||
|
|
||||||
def setup_client
|
def setup_client
|
||||||
@@channel.send Geoclue::Simple.new_sync("space.quietfeathers.Wince", Geoclue::AccuracyLevel::Street, nil)
|
callback = ->(object : GObject::Object | Nil, result : Gio::AsyncResult) {
|
||||||
Fiber.yield
|
@@client = Geoclue::Simple.new_finish(result)
|
||||||
|
puts "location callback"
|
||||||
|
}
|
||||||
|
|
||||||
|
Geoclue::Simple.new(
|
||||||
|
"space.quietfeathers.Wince",
|
||||||
|
Geoclue::AccuracyLevel::Street,
|
||||||
|
nil,
|
||||||
|
callback,
|
||||||
|
nil
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns latlon if available, otherwise empty array
|
# returns latlon if available, otherwise empty array
|
||||||
def find_location
|
def find_location
|
||||||
if !@@fiber.dead?
|
|
||||||
return [] of Float64
|
|
||||||
end
|
|
||||||
|
|
||||||
if @@client.nil?
|
if @@client.nil?
|
||||||
@@client = @@channel.receive
|
return [] of Float64
|
||||||
end
|
end
|
||||||
|
|
||||||
location = @@client.try do |c|
|
location = @@client.try do |c|
|
||||||
|
|||||||
Reference in New Issue
Block a user