koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
358 stars 67 forks source link

Example code fails at servers = master.get_servers #125

Closed ghost closed 12 years ago

ghost commented 12 years ago

On the usage page on the website, it says to query master servers in ruby:

master = MasterServer.new(_MasterServer::GOLDSRC_MASTER_SERVER) servers = master.get_servers server = GoldSrcServer.new(_servers.choice)

However...

$ gem install steam-condenser
3 gems installed
$ irb

>require 'steam-condenser'
=>true
>master = MasterServer.new(*MasterServer::GOLDSRC_MASTER_SERVER)
=>#<MasterServer:0x007fd6ba106d80 @host_names=["69.28.151.162"], @ip_addresses=["69.28.151.162"], @ip_index=0, @port=27010, @ip_address="69.28.151.162", @socket=#<MasterServerSocket:0x007fd6ba106c18 @socket=#<UDPSocket:fd 3>>> 
servers = master.get_servers
NoMethodError: undefined method `get_servers' for #<MasterServer:0x007fd6ba106d80>
    from (irb):3
    from /Users/auto/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
> servers = master.servers
SteamCondenser::TimeoutError: The operation timed out.
koraktor commented 12 years ago

Thanks for the hint on the website bug.

The timeout seems to indicate that the GoldSrc master server makes trouble once again. I'll have a look.

ghost commented 12 years ago

in the same example, it will also fail at server = GoldSrcServer.new(*servers.choice) choice is undefined as well.

koraktor commented 12 years ago

Well, #choice is a standard Ruby method for Arrays. It exists since 1.8.7, so you should either update or use something like this:

server = GoldSrcServer.new(*servers[rand server.count])

I won't update the example for that though. Ruby 1.8.6 is really outdated now.

ghost commented 12 years ago

My bad. Choice was renamed (and not aliased) to sample in Ruby > 1.8.7.

koraktor commented 12 years ago

Oh, that's a bit different story than, maybe I'll change it so it works on 1.9, 1.8.7 and 1.8.6.

koraktor commented 12 years ago

Sorry, I can't do anything about the master server problems, I think.

I'll have a look at it though and ask on the HLDS list.