I’m using the net-toc gem to connect to AIM with Ruby 1.8.7 since 1.9.2
doesn’t seem to support net-toc. The code below works fine if I input it
line by line into IRB, but it won’t create a connection and send an IM
if I run the code from a file($ ruby aim.rb). I’ve tried adding sleep(2)
after each connection to emulate the time it took me to write each line
in IRB, but that didn’t work either. Any ideas?
Do you have both 1.8.7 and 1.9.2 installed? If so, maybe you’re using
two
different versions–add “puts RUBY_VERSION” variable in irb and your rb
file.
My other guess would be that you might need something like EventMachine
to
handle asynchronous events, but I would look into the simpler solutions
first.
Waits for the event-handling thread for limit seconds, or indefinitely
if no
argument is given. Use this to prevent your program from exiting
prematurely…
I haven’t been able to get a ruby script to connect, and doing it in IRB
works for me, too. I think using client.wait (instead of sleep) is
going in
the right direction. I did a “puts client.buddy_list” in the client,
which
reported back my buddy list. However, doing this in the script printed
out
an empty line, so it looks like the connection isn’t completing. You
may
want to try playing with this some more–hope this helps