[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

works thro irb but not on commandline

Junkone

4/24/2008 8:23:00 PM

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()
7 Answers

Peter Jones

4/24/2008 8:59:00 PM

0

Junkone <junkone1@gmail.com> writes:
> 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?

--
Peter Jones [pjones at domain below]
pmade inc. - http:/...

Junkone

4/24/2008 9:31:00 PM

0

On Apr 24, 4:58 pm, Peter Jones <dev-n...@pmade.com> wrote:
> Junkone <junko...@gmail.com> writes:
> > 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?
>
> --
> Peter Jones [pjones at domain below]
> pmade inc. -http:/...


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>






dusty

4/24/2008 9:39:00 PM

0

Is net/toc a gem?

try adding

require 'rubygems'

to the top of the file

Junkone

4/24/2008 10:14:00 PM

0

On Apr 24, 5:39 pm, dusty <dusty.do...@gmail.com> wrote:
> 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.

Peter Jones

4/24/2008 10:16:00 PM

0

Junkone <junkone1@gmail.com> writes:
> 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.

--
Peter Jones [pjones at domain below]
pmade inc. - http:/...

Ken Bloom

4/25/2008 12:08:00 AM

0

On Thu, 24 Apr 2008 13:23:28 -0700, Junkone wrote:

> 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

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

Junkone

4/25/2008 1:16:00 AM

0

On Apr 24, 8:08 pm, Ken Bloom <kbl...@gmail.com> wrote:
> On Thu, 24 Apr 2008 13:23:28 -0700, Junkone wrote:
> > 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
>
> --
> Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory.
> Department of Computer Science. Illinois Institute of Technology.http://www.iit.edu/... Hide quoted text -
>
> - Show quoted text -

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