acpc_poker_basic_proxy 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/acpc_poker_basic_proxy.gemspec +4 -5
- data/lib/acpc_poker_basic_proxy.rb +1 -0
- data/lib/acpc_poker_basic_proxy/basic_proxy.rb +7 -4
- data/lib/acpc_poker_basic_proxy/communication_logic.rb +1 -2
- data/lib/acpc_poker_basic_proxy/communication_logic/action_sender.rb +3 -1
- data/lib/acpc_poker_basic_proxy/communication_logic/dealer_stream.rb +150 -0
- data/lib/acpc_poker_basic_proxy/version.rb +1 -1
- data/spec/action_sender_spec.rb +1 -1
- data/spec/basic_proxy_spec.rb +3 -3
- data/spec/coverage/index.html +7 -1373
- data/spec/dealer_stream_spec.rb +90 -0
- data/spec/match_state_receiver_spec.rb +1 -1
- data/spec/support/spec_helper.rb +2 -2
- metadata +98 -116
- data/lib/acpc_poker_basic_proxy/communication_logic/acpc_dealer_communicator.rb +0 -127
- data/lib/acpc_poker_basic_proxy/communication_logic/acpc_dealer_information.rb +0 -22
- data/lib/acpc_poker_basic_proxy/mixins/socket_with_ready_methods.rb +0 -32
- data/spec/acpc_dealer_communicator_spec.rb +0 -67
- data/spec/acpc_dealer_information_spec.rb +0 -10
@@ -0,0 +1,90 @@
|
|
1
|
+
|
2
|
+
require_relative 'support/spec_helper'
|
3
|
+
|
4
|
+
require 'socket'
|
5
|
+
|
6
|
+
require 'acpc_poker_basic_proxy/communication_logic/dealer_stream'
|
7
|
+
|
8
|
+
include AcpcPokerBasicProxy
|
9
|
+
include CommunicationLogic
|
10
|
+
|
11
|
+
describe DealerStream do
|
12
|
+
after do
|
13
|
+
end_test_connection!
|
14
|
+
end
|
15
|
+
describe '#new' do
|
16
|
+
it 'works properly' do
|
17
|
+
start_test_connection!
|
18
|
+
end_test_connection!
|
19
|
+
end
|
20
|
+
it "fails if the port doesn't correspond to a running server" do
|
21
|
+
fake_dealer = TCPServer.open(0)
|
22
|
+
port = fake_dealer.addr[1]
|
23
|
+
fake_dealer.close
|
24
|
+
-> { DealerStream.new(port) }.must_raise DealerStream::UnableToConnectToDealer
|
25
|
+
end
|
26
|
+
end
|
27
|
+
describe "#ready_to_read?" do
|
28
|
+
it 'lets the caller know that there is not new input from the dealer' do
|
29
|
+
connect_successfully!
|
30
|
+
@patient.ready_to_read?.must_equal false
|
31
|
+
end
|
32
|
+
it 'lets the caller know that there is new input from the dealer' do
|
33
|
+
connect_successfully!
|
34
|
+
@client_connection.puts "New input"
|
35
|
+
@patient.ready_to_read?.must_equal true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
describe "#ready_to_write?" do
|
39
|
+
it 'lets the caller know if the dealer is ready to receive data' do
|
40
|
+
connect_successfully!
|
41
|
+
@patient.ready_to_write?.must_equal true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
describe "#write" do
|
45
|
+
it "properly sends actions to the dealer" do
|
46
|
+
connect_successfully!
|
47
|
+
action = @match_state + ':c'
|
48
|
+
@patient.write action
|
49
|
+
|
50
|
+
@client_connection.gets.chomp.must_equal(action)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
describe "#gets" do
|
54
|
+
it "properly receives matchstate strings from the dealer" do
|
55
|
+
connect_successfully!
|
56
|
+
@client_connection.puts @match_state
|
57
|
+
@patient.gets.must_equal(@match_state)
|
58
|
+
end
|
59
|
+
it 'disconnects if the timeout is reached' do
|
60
|
+
[0, 100].each do |t|
|
61
|
+
start_test_connection! t
|
62
|
+
-> { @patient.gets }.must_raise DealerStream::UnableToGetFromDealer
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def end_test_connection!
|
68
|
+
@patient.close if @patient && !@patient.closed?
|
69
|
+
@client_connection.close if @client_connection && !@client_connection.closed?
|
70
|
+
end
|
71
|
+
|
72
|
+
def start_test_connection!(millisecond_response_timeout = 0, port = 0)
|
73
|
+
fake_dealer = TCPServer.open(port)
|
74
|
+
@patient = DealerStream.new(
|
75
|
+
fake_dealer.addr[1],
|
76
|
+
'localhost',
|
77
|
+
millisecond_response_timeout
|
78
|
+
)
|
79
|
+
@client_connection = fake_dealer.accept
|
80
|
+
end
|
81
|
+
|
82
|
+
def connect_successfully!
|
83
|
+
start_test_connection!
|
84
|
+
@client_connection.gets.chomp.must_equal(
|
85
|
+
"#{DealerStream::VERSION_LABEL}:#{DealerStream::VERSION_NUMBERS[:major]}.#{DealerStream::VERSION_NUMBERS[:minor]}.#{DealerStream::VERSION_NUMBERS[:revision]}"
|
86
|
+
)
|
87
|
+
|
88
|
+
@match_state = 'MATCHSTATE:0:0::5d5c'
|
89
|
+
end
|
90
|
+
end
|
@@ -5,7 +5,7 @@ require 'acpc_dealer'
|
|
5
5
|
require 'acpc_poker_types'
|
6
6
|
|
7
7
|
require 'acpc_poker_basic_proxy/communication_logic/match_state_receiver'
|
8
|
-
require 'acpc_poker_basic_proxy/communication_logic/
|
8
|
+
require 'acpc_poker_basic_proxy/communication_logic/dealer_stream'
|
9
9
|
|
10
10
|
describe AcpcPokerBasicProxy::CommunicationLogic::MatchStateReceiver do
|
11
11
|
before(:each) do
|
data/spec/support/spec_helper.rb
CHANGED
@@ -2,12 +2,12 @@ require 'simplecov'
|
|
2
2
|
SimpleCov.start
|
3
3
|
|
4
4
|
require 'minitest/spec'
|
5
|
-
require 'minitest/pride'
|
6
5
|
require 'minitest/mock'
|
6
|
+
|
7
7
|
require 'mocha/setup'
|
8
8
|
|
9
9
|
begin
|
10
|
-
require 'turn'
|
10
|
+
require 'turn/autorun'
|
11
11
|
|
12
12
|
Turn.config do |c|
|
13
13
|
# use one of output formats:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acpc_poker_basic_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Morrill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acpc_poker_types
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: contextual_exceptions
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: turn
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.13'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: acpc_dealer
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0.0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: awesome_print
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +128,14 @@ dependencies:
|
|
142
128
|
requirements:
|
143
129
|
- - ~>
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
131
|
+
version: '1.0'
|
146
132
|
type: :development
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
136
|
- - ~>
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
138
|
+
version: '1.0'
|
153
139
|
description: Basic proxy to connect to the ACPC Dealer.
|
154
140
|
email:
|
155
141
|
- morrill@ualberta.ca
|
@@ -157,73 +143,70 @@ executables: []
|
|
157
143
|
extensions: []
|
158
144
|
extra_rdoc_files: []
|
159
145
|
files:
|
160
|
-
- lib/acpc_poker_basic_proxy
|
161
|
-
- lib/acpc_poker_basic_proxy/communication_logic/acpc_dealer_information.rb
|
162
|
-
- lib/acpc_poker_basic_proxy/communication_logic/match_state_receiver.rb
|
163
|
-
- lib/acpc_poker_basic_proxy/communication_logic/acpc_dealer_communicator.rb
|
164
|
-
- lib/acpc_poker_basic_proxy/mixins/socket_with_ready_methods.rb
|
146
|
+
- lib/acpc_poker_basic_proxy.rb
|
165
147
|
- lib/acpc_poker_basic_proxy/basic_proxy.rb
|
166
148
|
- lib/acpc_poker_basic_proxy/communication_logic.rb
|
149
|
+
- lib/acpc_poker_basic_proxy/communication_logic/action_sender.rb
|
150
|
+
- lib/acpc_poker_basic_proxy/communication_logic/match_state_receiver.rb
|
151
|
+
- lib/acpc_poker_basic_proxy/communication_logic/dealer_stream.rb
|
167
152
|
- lib/acpc_poker_basic_proxy/version.rb
|
168
|
-
- lib/acpc_poker_basic_proxy.rb
|
169
153
|
- Rakefile
|
170
154
|
- acpc_poker_basic_proxy.gemspec
|
171
155
|
- README.md
|
172
|
-
- spec/
|
173
|
-
- spec/acpc_dealer_communicator_spec.rb
|
174
|
-
- spec/support/spec_helper.rb
|
175
|
-
- spec/support/dealer_logs/2p.nolimit.h1000.r0.actions.log
|
176
|
-
- spec/support/dealer_logs/2p.limit.h1000.r0.actions.log
|
177
|
-
- spec/support/dealer_logs/2p.nolimit.h1000.r0.log
|
178
|
-
- spec/support/dealer_logs/3p.nolimit.h1000.r0.log
|
156
|
+
- spec/match_state_receiver_spec.rb
|
179
157
|
- spec/support/dealer_logs/3p.limit.h1000.r0.actions.log
|
180
|
-
- spec/support/dealer_logs/3p.nolimit.h1000.r0.actions.log
|
181
158
|
- spec/support/dealer_logs/3p.limit.h1000.r0.log
|
159
|
+
- spec/support/dealer_logs/3p.nolimit.h1000.r0.actions.log
|
160
|
+
- spec/support/dealer_logs/2p.limit.h1000.r0.actions.log
|
161
|
+
- spec/support/dealer_logs/3p.nolimit.h1000.r0.log
|
162
|
+
- spec/support/dealer_logs/2p.nolimit.h1000.r0.log
|
163
|
+
- spec/support/dealer_logs/2p.nolimit.h1000.r0.actions.log
|
182
164
|
- spec/support/dealer_logs/2p.limit.h1000.r0.log
|
183
|
-
- spec/
|
184
|
-
- spec/
|
165
|
+
- spec/support/spec_helper.rb
|
166
|
+
- spec/basic_proxy_spec.rb
|
167
|
+
- spec/coverage/index.html
|
168
|
+
- spec/coverage/assets/0.7.1/application.js
|
169
|
+
- spec/coverage/assets/0.7.1/magnify.png
|
170
|
+
- spec/coverage/assets/0.7.1/favicon_yellow.png
|
171
|
+
- spec/coverage/assets/0.7.1/application.css
|
172
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
173
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png
|
174
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
175
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png
|
176
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
177
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png
|
178
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png
|
179
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
180
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
181
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png
|
182
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
183
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
184
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
185
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_title_right.png
|
186
|
+
- spec/coverage/assets/0.7.1/fancybox/fancybox-x.png
|
185
187
|
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png
|
186
188
|
- spec/coverage/assets/0.7.1/fancybox/fancybox.png
|
187
|
-
- spec/coverage/assets/0.7.1/fancybox/
|
188
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_nav_right.png
|
189
|
-
- spec/coverage/assets/0.7.1/fancybox/fancybox-y.png
|
190
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_title_right.png
|
189
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_title_over.png
|
191
190
|
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png
|
191
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_loading.png
|
192
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png
|
193
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_nav_right.png
|
192
194
|
- spec/coverage/assets/0.7.1/fancybox/fancy_nav_left.png
|
193
|
-
- spec/coverage/assets/0.7.1/fancybox/
|
195
|
+
- spec/coverage/assets/0.7.1/fancybox/fancybox-y.png
|
194
196
|
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png
|
195
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_loading.png
|
196
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_title_main.png
|
197
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_close.png
|
198
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_title_left.png
|
199
197
|
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png
|
200
|
-
- spec/coverage/assets/0.7.1/fancybox/
|
198
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png
|
199
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_close.png
|
200
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png
|
201
201
|
- spec/coverage/assets/0.7.1/fancybox/blank.gif
|
202
|
-
- spec/coverage/assets/0.7.1/fancybox/
|
203
|
-
- spec/coverage/assets/0.7.1/
|
204
|
-
- spec/coverage/assets/0.7.1/
|
205
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png
|
206
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
207
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png
|
208
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
209
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png
|
210
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png
|
211
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
212
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
213
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
214
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png
|
215
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
216
|
-
- spec/coverage/assets/0.7.1/loading.gif
|
217
|
-
- spec/coverage/assets/0.7.1/magnify.png
|
218
|
-
- spec/coverage/assets/0.7.1/application.js
|
219
|
-
- spec/coverage/assets/0.7.1/application.css
|
202
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_title_left.png
|
203
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_title_main.png
|
204
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png
|
220
205
|
- spec/coverage/assets/0.7.1/favicon_green.png
|
221
|
-
- spec/coverage/assets/0.7.1/favicon_yellow.png
|
222
206
|
- spec/coverage/assets/0.7.1/favicon_red.png
|
223
|
-
- spec/coverage/
|
224
|
-
- spec/
|
225
|
-
- spec/
|
226
|
-
- spec/basic_proxy_spec.rb
|
207
|
+
- spec/coverage/assets/0.7.1/loading.gif
|
208
|
+
- spec/dealer_stream_spec.rb
|
209
|
+
- spec/action_sender_spec.rb
|
227
210
|
homepage: https://github.com/dmorrill10/acpc_poker_basic_proxy
|
228
211
|
licenses: []
|
229
212
|
metadata: {}
|
@@ -243,63 +226,62 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
226
|
version: '0'
|
244
227
|
requirements: []
|
245
228
|
rubyforge_project: acpc_poker_basic_proxy
|
246
|
-
rubygems_version: 2.0.
|
229
|
+
rubygems_version: 2.0.0.rc.2
|
247
230
|
signing_key:
|
248
231
|
specification_version: 4
|
249
232
|
summary: ACPC Poker Basic Proxy
|
250
233
|
test_files:
|
251
|
-
- spec/
|
252
|
-
- spec/acpc_dealer_communicator_spec.rb
|
253
|
-
- spec/support/spec_helper.rb
|
254
|
-
- spec/support/dealer_logs/2p.nolimit.h1000.r0.actions.log
|
255
|
-
- spec/support/dealer_logs/2p.limit.h1000.r0.actions.log
|
256
|
-
- spec/support/dealer_logs/2p.nolimit.h1000.r0.log
|
257
|
-
- spec/support/dealer_logs/3p.nolimit.h1000.r0.log
|
234
|
+
- spec/match_state_receiver_spec.rb
|
258
235
|
- spec/support/dealer_logs/3p.limit.h1000.r0.actions.log
|
259
|
-
- spec/support/dealer_logs/3p.nolimit.h1000.r0.actions.log
|
260
236
|
- spec/support/dealer_logs/3p.limit.h1000.r0.log
|
237
|
+
- spec/support/dealer_logs/3p.nolimit.h1000.r0.actions.log
|
238
|
+
- spec/support/dealer_logs/2p.limit.h1000.r0.actions.log
|
239
|
+
- spec/support/dealer_logs/3p.nolimit.h1000.r0.log
|
240
|
+
- spec/support/dealer_logs/2p.nolimit.h1000.r0.log
|
241
|
+
- spec/support/dealer_logs/2p.nolimit.h1000.r0.actions.log
|
261
242
|
- spec/support/dealer_logs/2p.limit.h1000.r0.log
|
262
|
-
- spec/
|
263
|
-
- spec/
|
243
|
+
- spec/support/spec_helper.rb
|
244
|
+
- spec/basic_proxy_spec.rb
|
245
|
+
- spec/coverage/index.html
|
246
|
+
- spec/coverage/assets/0.7.1/application.js
|
247
|
+
- spec/coverage/assets/0.7.1/magnify.png
|
248
|
+
- spec/coverage/assets/0.7.1/favicon_yellow.png
|
249
|
+
- spec/coverage/assets/0.7.1/application.css
|
250
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
251
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png
|
252
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
253
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png
|
254
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
255
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png
|
256
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png
|
257
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
258
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
259
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png
|
260
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
261
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
262
|
+
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
263
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_title_right.png
|
264
|
+
- spec/coverage/assets/0.7.1/fancybox/fancybox-x.png
|
264
265
|
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png
|
265
266
|
- spec/coverage/assets/0.7.1/fancybox/fancybox.png
|
266
|
-
- spec/coverage/assets/0.7.1/fancybox/
|
267
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_nav_right.png
|
268
|
-
- spec/coverage/assets/0.7.1/fancybox/fancybox-y.png
|
269
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_title_right.png
|
267
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_title_over.png
|
270
268
|
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png
|
269
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_loading.png
|
270
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png
|
271
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_nav_right.png
|
271
272
|
- spec/coverage/assets/0.7.1/fancybox/fancy_nav_left.png
|
272
|
-
- spec/coverage/assets/0.7.1/fancybox/
|
273
|
+
- spec/coverage/assets/0.7.1/fancybox/fancybox-y.png
|
273
274
|
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png
|
274
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_loading.png
|
275
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_title_main.png
|
276
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_close.png
|
277
|
-
- spec/coverage/assets/0.7.1/fancybox/fancy_title_left.png
|
278
275
|
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png
|
279
|
-
- spec/coverage/assets/0.7.1/fancybox/
|
276
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png
|
277
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_close.png
|
278
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png
|
280
279
|
- spec/coverage/assets/0.7.1/fancybox/blank.gif
|
281
|
-
- spec/coverage/assets/0.7.1/fancybox/
|
282
|
-
- spec/coverage/assets/0.7.1/
|
283
|
-
- spec/coverage/assets/0.7.1/
|
284
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png
|
285
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
286
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png
|
287
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
288
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png
|
289
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png
|
290
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
291
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
292
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
293
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png
|
294
|
-
- spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
295
|
-
- spec/coverage/assets/0.7.1/loading.gif
|
296
|
-
- spec/coverage/assets/0.7.1/magnify.png
|
297
|
-
- spec/coverage/assets/0.7.1/application.js
|
298
|
-
- spec/coverage/assets/0.7.1/application.css
|
280
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_title_left.png
|
281
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_title_main.png
|
282
|
+
- spec/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png
|
299
283
|
- spec/coverage/assets/0.7.1/favicon_green.png
|
300
|
-
- spec/coverage/assets/0.7.1/favicon_yellow.png
|
301
284
|
- spec/coverage/assets/0.7.1/favicon_red.png
|
302
|
-
- spec/coverage/
|
303
|
-
- spec/
|
304
|
-
- spec/
|
305
|
-
- spec/basic_proxy_spec.rb
|
285
|
+
- spec/coverage/assets/0.7.1/loading.gif
|
286
|
+
- spec/dealer_stream_spec.rb
|
287
|
+
- spec/action_sender_spec.rb
|
@@ -1,127 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'socket'
|
3
|
-
require 'dmorrill10-utils/class'
|
4
|
-
|
5
|
-
require 'acpc_poker_basic_proxy/mixins/socket_with_ready_methods'
|
6
|
-
|
7
|
-
# Communication service to the ACPC Dealer.
|
8
|
-
# It acts solely as an abstraction of the communication protocol and
|
9
|
-
# implements the main Ruby communication interface through 'gets' and 'puts'
|
10
|
-
# methods.
|
11
|
-
module AcpcPokerBasicProxy
|
12
|
-
module CommunicationLogic
|
13
|
-
class AcpcDealerCommunicator
|
14
|
-
exceptions :acpc_dealer_connection_error, :put_to_acpc_dealer_error, :get_from_acpc_dealer_error
|
15
|
-
|
16
|
-
# @return [String] The ACPC dealer version label.
|
17
|
-
VERSION_LABEL = 'VERSION'
|
18
|
-
|
19
|
-
# @return [Hash] The ACPC dealer version numbers.
|
20
|
-
VERSION_NUMBERS = {:major => 2, :minor => 0, :revision => 0}
|
21
|
-
|
22
|
-
# @return [String] Dealer specified string terminator.
|
23
|
-
TERMINATION_STRING = "\r\n"
|
24
|
-
|
25
|
-
# @param [Integer] port The port on which to connect to the dealer.
|
26
|
-
# @param [String] host_name The host on which the dealer is running.
|
27
|
-
# @param [Integer] millisecond_response_timeout The dealer's response timeout, in milleseconds.
|
28
|
-
# @raise AcpcDealerConnectionError, PutToAcpcDealerError
|
29
|
-
def initialize(port, host_name='localhost', millisecond_response_timeout=nil)
|
30
|
-
begin
|
31
|
-
@dealer_socket = TCPSocket.new(host_name, port)
|
32
|
-
@response_timeout_in_seconds = if millisecond_response_timeout
|
33
|
-
millisecond_response_timeout/(10**3)
|
34
|
-
else
|
35
|
-
nil
|
36
|
-
end
|
37
|
-
send_version_string_to_dealer
|
38
|
-
rescue PutToAcpcDealerError
|
39
|
-
raise
|
40
|
-
rescue
|
41
|
-
handle_error AcpcDealerConnectionError, "Unable to connect to the dealer on #{host_name} through port #{port}: #{$?}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Closes the connection to the dealer.
|
46
|
-
def close
|
47
|
-
@dealer_socket.close if @dealer_socket
|
48
|
-
end
|
49
|
-
|
50
|
-
# Retrieves a string from the dealer.
|
51
|
-
#
|
52
|
-
# @return [String] A string from the dealer.
|
53
|
-
# @raise GetFromAcpcDealerError
|
54
|
-
def gets
|
55
|
-
begin
|
56
|
-
raw_match_state = string_from_dealer
|
57
|
-
rescue
|
58
|
-
handle_error GetFromAcpcDealerError, "Unable to get a string from the dealer: #{$?}"
|
59
|
-
end
|
60
|
-
raw_match_state
|
61
|
-
end
|
62
|
-
|
63
|
-
# Sends a given +string+ to the dealer.
|
64
|
-
#
|
65
|
-
# @param [String] string The string to send.
|
66
|
-
# @return (see #send_string_to_dealer)
|
67
|
-
# @raise WriteToAcpcDealerError
|
68
|
-
def write(string)
|
69
|
-
begin
|
70
|
-
bytes_written = send_string_to_dealer string
|
71
|
-
rescue
|
72
|
-
handle_error GetFromAcpcDealerError, "Unable to send the string, \"#{string}\", to the dealer: #{$?}."
|
73
|
-
end
|
74
|
-
bytes_written
|
75
|
-
end
|
76
|
-
|
77
|
-
# @see TCPSocket#ready_to_write?
|
78
|
-
def ready_to_write?
|
79
|
-
@dealer_socket.ready_to_write? @response_timeout_in_seconds
|
80
|
-
end
|
81
|
-
|
82
|
-
# @see TCPSocket#ready_to_read?
|
83
|
-
def ready_to_read?
|
84
|
-
@dealer_socket.ready_to_read? @response_timeout_in_seconds
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def handle_error(exception, message)
|
90
|
-
close
|
91
|
-
raise exception, message
|
92
|
-
end
|
93
|
-
|
94
|
-
# @return (see #send_string_to_dealer)
|
95
|
-
def send_version_string_to_dealer
|
96
|
-
version_string = "#{VERSION_LABEL}:#{VERSION_NUMBERS[:major]}.#{VERSION_NUMBERS[:minor]}.#{VERSION_NUMBERS[:revision]}"
|
97
|
-
begin
|
98
|
-
bytes_written = send_string_to_dealer version_string
|
99
|
-
rescue
|
100
|
-
handle_error PutToAcpcDealerError, "Unable to send version string, \"#{version_string}\", to the dealer"
|
101
|
-
end
|
102
|
-
bytes_written
|
103
|
-
end
|
104
|
-
|
105
|
-
# @return [Integer] The number of bytes written to the dealer.
|
106
|
-
def send_string_to_dealer(string)
|
107
|
-
raise unless ready_to_write?
|
108
|
-
begin
|
109
|
-
bytes_written = @dealer_socket.write(string + TERMINATION_STRING)
|
110
|
-
rescue
|
111
|
-
raise
|
112
|
-
end
|
113
|
-
bytes_written
|
114
|
-
end
|
115
|
-
|
116
|
-
def string_from_dealer
|
117
|
-
raise unless ready_to_read?
|
118
|
-
begin
|
119
|
-
string = @dealer_socket.gets.chomp
|
120
|
-
rescue
|
121
|
-
raise
|
122
|
-
end
|
123
|
-
string
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|