Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

DragonRuby Game Toolkit

An intuitive 2D game engine. Fast, cross-platform, tiny, hot loaded. · By DragonRuby

Using DragonRuby as a renderer -- how do I make it wait for new data?

A topic by Nakilon created 63 days ago Views: 194 Replies: 2
Viewing posts 1 to 3
(11 edits)

Hello.

I would like to use the DragonRuby as a renderer for games/programs that are running on real Ruby in another process. The "main" process should send updates when needed (and should potentially be allowed to die and start later) to the "second" process that is the DragonRuby renderer. The problem I see here is that DragonRuby wants me to repeat the loop again and again instead of doing nothing while waiting for data. I wanted to use https://en.wikipedia.org/wiki/Named_pipe for communication where if you open it as a file the `gets` waits for data but here it seems that I can't wait. Another option would be make the 3rd (!) proxy updates-accumulating process with something like webrick and use `$gtk.http_get` but that seems to be overkill.

Or... I just didn't really try to run the DragonRuby yet -- maybe it's ok to stuck and not return from the `tick` iteration in time? But then I don't see where are docs on the `gtk` object to check if it can work with fifo -- grep gives me `gtk.read_file` examples but not `gets`.

Developer

Take a look at the “mailbox” sample app. That is a poor man’s out of proc communication.

(7 edits)

When I do the

curl http://localhost:8001

I see it my webrick access_log but

p 1
x ||= $gtk.http_get "http://localhost:8001/"
p 2

prints lots of 1 and 2 but nothing in access_log. Maybe because http_get does not accept port? Or what else can be wrong here?

Also the x is nil all the time.

UPD: 

dragonruby-macos/samples/24_http_example also shows just black window after the warning text disappears

$ ./dragonruby-macos/samples/24_http_example/run

and the `args.state.download.class` is similarly `NilClass` before and after the `= $gtk.http_get` line.

UPD: updated to git SHA -- a2ea0c036fe67a406a654fd8e40abd167e3b6ac7

Same black window.