works thro irb but not on commandline

J

Junkone

i have a strange prob. when i run this code under irb, the buddy can
recieve the message. when i run it under the ruby commandline, the
buddy does not recive the message. i am not sure what the difference
is.
any pointers is appreciated.


require 'net/toc'
client = Net::TOC.new("userid","password")
client.connect
client.wait(10)
friend = client.buddy_list.buddy_named("mybuddy1")
client.on_im do | message, buddy |
puts "#{buddy.screen_name}: #{message}"
end
client.on_error do | error |
puts "!! #{error}"
end

friend.send_im(" hi how going") # not sure why this is not being
sent.
puts client.buddy_list.to_s

client.disconnect()
 
P

Peter Jones

Junkone said:
i have a strange prob. when i run this code under irb, the buddy can
recieve the message. when i run it under the ruby commandline, the
buddy does not recive the message. i am not sure what the difference
is.

Are there any error messages associated with it not working? Have you
checked your ~/.irbrc to make sure there's nothing in there that would
be letting this work, that you don't have in the source file you are
trying?

Have you written any test code to show it working vs. not working?
 
J

Junkone

Are there any error messages associated with it not working?  Have you
checked your ~/.irbrc to make sure there's nothing in there that would
be letting this work, that you don't have in the source file you are
trying?

Have you written any test code to show it working vs. not working?


i have the aol im on my machine connected as one of the buddies
i cut and paste the code from the aimbot.rb file and execute them line
by line and when i hit
friend.send_im(" hi how going")
i get the IM on my aol client.

when i execute the aimbot.rb the message does not popup on my aim
client. i get no errors. nothing. beats the hell out of me.

require 'net/toc'
client = Net::TOC.new("userid","password")
client.connect
friend = client.buddy_list.buddy_named("mybuddy")
friend.send_im(" hi how going")
client.disconnect()


the irb is the same code as above. no typeing. just cut and paste


E:\Documents and Settings\User1>irb
irb(main):001:0> require 'net/toc'
=> true
irb(main):002:0> client = Net::TOC.new("userid","password")
=> #<Net::TOC::Client:0x2eadb64 @buddy_list=#<Net::TOC::BuddyList:
0x2eada88 @buddies={}, @group_order=[],
onn=#<Net::TOC::Connection:0x2eadb3c @msgseq=65919,
@user="trad2win">>, @screen_name="trad2win", @callbac
<Proc:0x02ebb930@e:/ruby/lib/ruby/gems/1.8/gems/net-toc-0.2/./net/
toc.rb:436>, :config=>#<Proc:0x02ebb930
by/gems/1.8/gems/net-toc-0.2/./net/toc.rb:436>, :update_buddy=>#<Proc:
0x02ebb584@e:/ruby/lib/ruby/gems/1.
0.2/./net/toc.rb:437>, :error=>#<Proc:0x02eb6ea8@e:/ruby/lib/ruby/gems/
1.8/gems/net-toc-0.2/./net/toc.rb:
uddy2=>#<Proc:0x02ebb584@e:/ruby/lib/ruby/gems/1.8/gems/net-toc-0.2/./
net/toc.rb:437>}, @password="password::TOC::Connection:0x2eadb3c
@msgseq=65919, @user="userid">>
irb(main):003:0> client.connect
=> #<Thread:0x2eab6d4 sleep>
irb(main):004:0> friend = client.buddy_list.buddy_named("mybuddy")
=> #<Net::TOC::Buddy:0x2ea8754 @screen_name="mybuddy",
@last_signon=Thu Apr 24 15:43:28 -0400 2008,
ble, @on_status={}, @conn=#<Net::TOC::Connection:0x2eadb3c
@msgseq=65923, @user="userid", @sock=#<TCPSo
, @idle_time=0, @warning_level=0>
irb(main):005:0> friend.send_im(" hi how going")
=> 47
irb(main):006:0> client.disconnect
=> nil
irb(main):007:0>
 
J

Junkone

Is net/toc a gem?

try adding

require 'rubygems'

to the top of the file

nope. it makes no difference. i even opened the gem and added a puts
"i am here" line and can see it sending the message. but the client is
not flashing the mesg if it not from IRB.

strangest thing i have seen.
 
P

Peter Jones

Junkone said:
i have the aol im on my machine connected as one of the buddies
i cut and paste the code from the aimbot.rb file and execute them line
by line and when i hit
friend.send_im(" hi how going")
i get the IM on my aol client.

I don't think there's much anyone can do for you until you narrow this
a bit further down.

I honestly think that you should start by writing some tests. If it
were me, I'd use some test code from the gem you are using so that
you didn't need to use any GUI client to confirm delivery.

I might also write a test that used tcpdump(1) to look for the packets
leaving the interface, and assert that they are actually being sent.

I'm assuming from your connect call that this protocol is based on TCP
and not UDP. At the very least, using tcpdump should help you
understand where the error is, on the sending side or the receiving
side.

Good luck.
 
K

Ken Bloom

i have a strange prob. when i run this code under irb, the buddy can
recieve the message. when i run it under the ruby commandline, the buddy
does not recive the message. i am not sure what the difference is.
any pointers is appreciated.


require 'net/toc'
client = Net::TOC.new("userid","password") client.connect
client.wait(10)
friend = client.buddy_list.buddy_named("mybuddy1") client.on_im do |
message, buddy |
puts "#{buddy.screen_name}: #{message}"
end
client.on_error do | error |
puts "!! #{error}"
end

friend.send_im(" hi how going") # not sure why this is not being
sent.
puts client.buddy_list.to_s

client.disconnect()

Try sleeping for a second after sending the message, but before
disconnecting, and see if that fixes it. (Maybe it's some kind of
asynchronous communication issue in net/toc.)

--Ken
 
J

Junkone

Try sleeping for a second after sending the message, but before
disconnecting, and see if that fixes it. (Maybe it's some kind of
asynchronous communication issue in net/toc.)

--Ken

--
Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.http://www.iit.edu/~kbloom1/- Hide quoted text -

- Show quoted text -

ok. the sleep worked. that was smart of you.
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top