@@ -60,7 +60,11 @@ public interface EventHandler {
60
60
private ByteBuffer mapFileHandle = null ;
61
61
private ByteBuffer gameTableFileHandle = null ;
62
62
63
- Client () {}
63
+ private boolean debugConnection = false ;
64
+
65
+ Client (boolean debugConnection ) {
66
+ this .debugConnection = debugConnection ;
67
+ }
64
68
65
69
/**
66
70
* For test purposes only
@@ -89,6 +93,10 @@ void reconnect(){
89
93
}
90
94
91
95
void disconnect () {
96
+ if (debugConnection ) {
97
+ System .err .print ("Disconnect called by: " );
98
+ System .err .println (Thread .currentThread ().getStackTrace ()[2 ].getMethodName ());
99
+ }
92
100
if (!connected ) {
93
101
return ;
94
102
}
@@ -126,6 +134,9 @@ boolean connect() {
126
134
}
127
135
catch (Exception e ) {
128
136
System .err .println ("Game table mapping not found." );
137
+ if (debugConnection ) {
138
+ e .printStackTrace ();
139
+ }
129
140
return false ;
130
141
}
131
142
@@ -135,6 +146,9 @@ boolean connect() {
135
146
}
136
147
catch (Exception e ) {
137
148
System .err .println ("Unable to map Game table." );
149
+ if (debugConnection ) {
150
+ e .printStackTrace ();
151
+ }
138
152
return false ;
139
153
}
140
154
@@ -166,6 +180,9 @@ boolean connect() {
166
180
}
167
181
catch (Exception e ) {
168
182
System .err .println ("Unable to open communications pipe: " + communicationPipe );
183
+ if (debugConnection ) {
184
+ e .printStackTrace ();
185
+ }
169
186
gameTableFileHandle = null ;
170
187
return false ;
171
188
}
@@ -178,6 +195,9 @@ boolean connect() {
178
195
}
179
196
catch (Exception e ) {
180
197
System .err .println ("Unable to open shared memory mapping: " + sharedMemoryName );
198
+ if (debugConnection ) {
199
+ e .printStackTrace ();
200
+ }
181
201
pipeObjectHandle = null ;
182
202
gameTableFileHandle = null ;
183
203
return false ;
@@ -188,6 +208,9 @@ boolean connect() {
188
208
}
189
209
catch (Exception e ) {
190
210
System .err .println ("Unable to map game data." );
211
+ if (debugConnection ) {
212
+ e .printStackTrace ();
213
+ }
191
214
return false ;
192
215
}
193
216
@@ -205,8 +228,11 @@ boolean connect() {
205
228
code = pipeObjectHandle .readByte ();
206
229
}
207
230
catch (Exception e ) {
208
- disconnect ();
209
231
System .err .println ("Unable to read pipe object." );
232
+ if (debugConnection ) {
233
+ e .printStackTrace ();
234
+ }
235
+ disconnect ();
210
236
return false ;
211
237
}
212
238
}
@@ -223,6 +249,9 @@ void update(final EventHandler handler) {
223
249
}
224
250
catch (Exception e ) {
225
251
System .err .println ("failed, disconnecting" );
252
+ if (debugConnection ) {
253
+ e .printStackTrace ();
254
+ }
226
255
disconnect ();
227
256
return ;
228
257
}
@@ -232,6 +261,9 @@ void update(final EventHandler handler) {
232
261
}
233
262
catch (Exception e ) {
234
263
System .err .println ("failed, disconnecting" );
264
+ if (debugConnection ) {
265
+ e .printStackTrace ();
266
+ }
235
267
disconnect ();
236
268
return ;
237
269
}
0 commit comments