teamspeak-ruby 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48a7dab7b91961d54bacdea425abe4a996dc24f0
4
- data.tar.gz: 03f19e56293c044f8fb44e416f6d03ce245072e9
3
+ metadata.gz: f5293306a7bf6d98ffcd5bd9b7147d8d336636d1
4
+ data.tar.gz: 4f587d29775bd5d368c85529f965d3785da38049
5
5
  SHA512:
6
- metadata.gz: acc5f352ce5c12942d29d498aa0cb68bcc241295ed2dd469fc3ef2c991afe5a6fbedd158149d3634e59f18e62f08711a90107a35517de64e42bb7b79c18b988e
7
- data.tar.gz: 5e7cfecfc5f0bca28bac5a8e3034f1c76299fbd6d88879614b06809ac501ee9a7de6c82661bba11081e8a789920664c69b27e92173f5c2be091653989676f603
6
+ metadata.gz: c9ce3a70837d0945f47ac485386ad64ccc0a125705871b0bcac7ebf44775fa52b68082bd4be7c2a18efc11567d27156718dbba035c37a890f0b175752ae2be30
7
+ data.tar.gz: a1c1aed6910489fd9fab73ba9f9fbc32c407cf71bdd1d72182fdac4ef70870da0d82a72312fb8a6292c71f8c3c43fc150191b6faa1611f02f4d289bfacde3bed
@@ -51,27 +51,12 @@ module Teamspeak
51
51
  def login(user, pass)
52
52
  command('login', {'client_login_name' => user, 'client_login_password' => pass})
53
53
  end
54
-
54
+
55
55
  # Sends command to the TeamSpeak 3 server and returns the response
56
56
  #
57
57
  # command('use', {'sid' => 1}, '-away')
58
58
  def command(cmd, params = {}, options = '')
59
- if @flood_protection
60
- @flood_current += 1
61
-
62
- flood_time_reached = Time.now - @flood_timer < @flood_time
63
- flood_limit_reached = @flood_current == @flood_limit
64
-
65
- if flood_time_reached && flood_limit_reached
66
- sleep(@flood_time)
67
- end
68
-
69
- if flood_limit_reached
70
- # Reset flood protection
71
- @flood_timer = Time.now
72
- @flood_current = 0
73
- end
74
- end
59
+ flood_control
75
60
 
76
61
  out = ''
77
62
  response = ''
@@ -86,6 +71,11 @@ module Teamspeak
86
71
 
87
72
  @sock.puts out
88
73
 
74
+ if cmd == 'servernotifyregister'
75
+ 2.times {response += @sock.gets}
76
+ return parse_response(response)
77
+ end
78
+
89
79
  while true
90
80
  response += @sock.gets
91
81
 
@@ -173,6 +163,28 @@ module Teamspeak
173
163
  raise ServerError.new(id, message) unless id == 0
174
164
  end
175
165
 
176
- private(:parse_response, :decode_param, :encode_param, :check_response_error)
166
+ def flood_control
167
+ if @flood_protection
168
+ @flood_current += 1
169
+
170
+ flood_time_reached = Time.now - @flood_timer < @flood_time
171
+ flood_limit_reached = @flood_current == @flood_limit
172
+
173
+ if flood_time_reached && flood_limit_reached
174
+ sleep(@flood_time)
175
+ end
176
+
177
+ if flood_limit_reached
178
+ # Reset flood protection
179
+ @flood_timer = Time.now
180
+ @flood_current = 0
181
+ end
182
+ end
183
+ end
184
+
185
+ private(
186
+ :parse_response, :decode_param, :encode_param,
187
+ :check_response_error, :flood_control
188
+ )
177
189
  end
178
190
  end
@@ -1,3 +1,3 @@
1
1
  module Teamspeak
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamspeak-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Harrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-31 00:00:00.000000000 Z
11
+ date: 2015-05-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: justin@pyrohail.com
@@ -45,4 +45,3 @@ signing_key:
45
45
  specification_version: 4
46
46
  summary: Ruby interface for TeamSpeak 3's server query api.
47
47
  test_files: []
48
- has_rdoc: