Ruby, rubygame, eventmachine

P

Piotr S.

Hey guys.
I've been doing stuff with rubygame library where I limited ticks to 60
per second using @clock.target_framerate = 60.
I need to implement eventmachine to handle UDP connections to the
server. The problem is that I can't seem to get the whole idea of
EventMachine::run.
I want to schedule receiving and sending data in my main loop so that
every 2 loops it recieves data from the buffer (receive_data would just
put everything into the buffer) and at the end of the same loop it sends
data to the server.
Since UDP sockets in ruby 1.9.2 (at least on my computer) are not
working in nonblocking mode I'm trying to do the job with the
EventMachine.
EM.add_periodic_timer is too slow because it doesn't get any faster than
maybe 0.2 s and EM.tick_loop isn't even recognized. Help me out.
 
P

Piotr S.

It seems to be working using EM.tick_loop but instead of require
'eventmachine' you have to require './eventmahine/examples/helper' (for
some reason there is eventmachine folder inside of my ruby projects
folder ;D )
It does about 160k { i += 1; p i in 5 } seconds while taking calls from
receive_data. Beautiful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top