gamespy_query 0.2.0pre10 → 0.2.0pre11
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/gamespy_query +0 -0
- data/lib/gamespy_query/base.rb +8 -13
- data/lib/gamespy_query/master.rb +1 -1
- data/lib/gamespy_query/socket_master.rb +12 -8
- data/lib/gamespy_query/version.rb +1 -1
- metadata +2 -2
data/bin/gamespy_query
CHANGED
File without changes
|
data/lib/gamespy_query/base.rb
CHANGED
@@ -106,20 +106,15 @@ STR
|
|
106
106
|
# Convert string to UTF-8, stripping out all invalid/undefined characters
|
107
107
|
# @param [String] str String to convert
|
108
108
|
def encode_string(str)
|
109
|
-
#
|
110
|
-
#System::Text::Encoding.UTF8.GetString(System::Array.of(System::Byte).new(str.bytes.to_a)).to_s
|
111
|
-
#
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
rescue nil, Exception => e
|
117
|
-
# Fallback - convert to UTF and replace any invalid or undefined
|
118
|
-
Tools.log_exception e
|
119
|
-
str.encode(STR_UTF8, invalid: :replace, undef: :replace)
|
120
|
-
end
|
121
|
-
=end
|
109
|
+
#if RUBY_PLATFORM =~ PLATFORM_IR
|
110
|
+
# System::Text::Encoding.UTF8.GetString(System::Array.of(System::Byte).new(str.bytes.to_a)).to_s
|
111
|
+
#else
|
112
|
+
# str.encode(STR_UTF8, STR_UTF8, invalid: :replace, undef: :replace)
|
113
|
+
#end
|
114
|
+
str.encode(STR_UTF8, STR_UTF8, invalid: :replace, undef: :replace)
|
115
|
+
rescue nil, Exception => e
|
122
116
|
# Fallback - convert to UTF and replace any invalid or undefined
|
117
|
+
Tools.log_exception e
|
123
118
|
str.encode(STR_UTF8, invalid: :replace, undef: :replace)
|
124
119
|
end
|
125
120
|
end
|
data/lib/gamespy_query/master.rb
CHANGED
@@ -54,7 +54,7 @@ module GamespyQuery
|
|
54
54
|
# @param [String] geo Geo String
|
55
55
|
def get_server_list list = nil, include_data = false, geo = nil
|
56
56
|
addrs = []
|
57
|
-
list = %x[gslist -p "#{geoip_path}"#{" #{geo}-X #{get_params}" if include_data} -n #{@game}] if list.nil?
|
57
|
+
list = %x[gslist -C -p "#{geoip_path}"#{" #{geo}-X #{get_params}" if include_data} -n #{@game}] if list.nil?
|
58
58
|
if include_data
|
59
59
|
addrs = handle_data(list, geo)
|
60
60
|
else
|
@@ -29,7 +29,7 @@ module GamespyQuery
|
|
29
29
|
def process! use_threads = DEFAULT_THREADS
|
30
30
|
sockets = []
|
31
31
|
if use_threads.to_i > 0
|
32
|
-
monitor = Monitor.new
|
32
|
+
monitor = Monitor.new
|
33
33
|
threads = []
|
34
34
|
addrs_list = @addrs.each_slice(@addrs.size / use_threads).to_a
|
35
35
|
use_threads.times.each do |i|
|
@@ -38,14 +38,18 @@ module GamespyQuery
|
|
38
38
|
puts "Spawning thread #{i}" if @info
|
39
39
|
|
40
40
|
threads << Thread.new(list, i) do |addrs, id|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
begin
|
42
|
+
puts "Thread: #{id} Start, #{addrs.size}" if @info
|
43
|
+
out = proc(addrs)
|
44
|
+
|
45
|
+
puts "Thread: #{id} Pushing output to list. #{out.size}" if @info
|
46
|
+
monitor.synchronize do
|
47
|
+
sockets += out
|
48
|
+
end
|
49
|
+
puts "Thread: #{id} End" if @info
|
50
|
+
ensure
|
51
|
+
ActiveRecord::Base.connection_pool.release_connection
|
47
52
|
end
|
48
|
-
puts "Thread: #{id} End" if @info
|
49
53
|
end
|
50
54
|
end
|
51
55
|
threads.each {|t| t.join}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamespy_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.0pre11
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cri
|