G
Gin Mendi
I think I'm a little over my head here and was hoping someone more
experienced can explain this to me, a novice trying to learn ruby.
I'm currently trying to use a win32 DLL to get a live feed of data from
a server. With the help of some people form this forum, I was able to
make a module using ruby/dl to use the functions on the DLL. I'm
currently able to log on to the server, request snapshot data and log
off. Now I'm trying to use the live feed functions from the library.
These are functions where I pass a few parameters and a callback
function. The function then returns a pointer to the session object and
calls the callback function whenever an update occurs on their end.
I tried to make a simple implementation where I log on, request for a
live feed, and keep the program running and print out the data I get
from the server using the callback function I provide.
So here's what I did to test things out:
feed_library.rb is my module using ruby/dl to access the dll functions,
as well as the structures I use to convert the pointers to records
require 'feed_library'
# my callback for the live feed
FEED_CALLBACK = DL.callback('0PL') { |result_list, count| }
if result_list
record = FeedRecord.new(result_list)
puts record
end
}
# handle used to request for a feed
handle = FeedLibrary::log_on("user", "password")
session = get_live_feed(handle, FEED_CALLBACK)
# my attempt to keep this running and waiting on the callback:
while true
end
Whenever I run this I get the cross-thread violation on
rb_thread_schedule() error. Been trying to read on other topics on this
but I couldn't fully grasp the discussion. Can anyone explain what's
happening and what would be the best approach in getting the feed?
Thanks for taking the time to read this
experienced can explain this to me, a novice trying to learn ruby.
I'm currently trying to use a win32 DLL to get a live feed of data from
a server. With the help of some people form this forum, I was able to
make a module using ruby/dl to use the functions on the DLL. I'm
currently able to log on to the server, request snapshot data and log
off. Now I'm trying to use the live feed functions from the library.
These are functions where I pass a few parameters and a callback
function. The function then returns a pointer to the session object and
calls the callback function whenever an update occurs on their end.
I tried to make a simple implementation where I log on, request for a
live feed, and keep the program running and print out the data I get
from the server using the callback function I provide.
So here's what I did to test things out:
feed_library.rb is my module using ruby/dl to access the dll functions,
as well as the structures I use to convert the pointers to records
require 'feed_library'
# my callback for the live feed
FEED_CALLBACK = DL.callback('0PL') { |result_list, count| }
if result_list
record = FeedRecord.new(result_list)
puts record
end
}
# handle used to request for a feed
handle = FeedLibrary::log_on("user", "password")
session = get_live_feed(handle, FEED_CALLBACK)
# my attempt to keep this running and waiting on the callback:
while true
end
Whenever I run this I get the cross-thread violation on
rb_thread_schedule() error. Been trying to read on other topics on this
but I couldn't fully grasp the discussion. Can anyone explain what's
happening and what would be the best approach in getting the feed?
Thanks for taking the time to read this