diff options
author | Pacien TRAN-GIRARD | 2016-05-26 15:28:44 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-05-26 15:28:44 +0200 |
commit | 5294d9779dec5b36ccdf1c87b768bddf91179171 (patch) | |
tree | bdc9923a57faeff3e7ff8269af1710deb0ff0174 /src/ch/epfl | |
parent | 4ab73ab0a0e931666bc95739896dbebfb26e218f (diff) | |
download | xblast-5294d9779dec5b36ccdf1c87b768bddf91179171.tar.gz |
Elaborate doc
Diffstat (limited to 'src/ch/epfl')
-rw-r--r-- | src/ch/epfl/xblast/client/Client.java | 47 | ||||
-rw-r--r-- | src/ch/epfl/xblast/client/Main.java | 2 | ||||
-rw-r--r-- | src/ch/epfl/xblast/client/XBlastComponent.java | 24 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Main.java | 2 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Server.java | 44 |
5 files changed, 60 insertions, 59 deletions
diff --git a/src/ch/epfl/xblast/client/Client.java b/src/ch/epfl/xblast/client/Client.java index 8ccea00..24ca727 100644 --- a/src/ch/epfl/xblast/client/Client.java +++ b/src/ch/epfl/xblast/client/Client.java | |||
@@ -40,7 +40,7 @@ public class Client { | |||
40 | private static class Channel { | 40 | private static class Channel { |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Transform a buffer to a list of bytes. | 43 | * Transforms a buffer to a list of bytes. |
44 | * | 44 | * |
45 | * @param buf given buffer | 45 | * @param buf given buffer |
46 | * @return the list of bytes built from the given buffer | 46 | * @return the list of bytes built from the given buffer |
@@ -55,7 +55,7 @@ public class Client { | |||
55 | } | 55 | } |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Create the UDP communication Channel. | 58 | * Creates the UDP communication Channel. |
59 | * | 59 | * |
60 | * @return the UDP communication Channel | 60 | * @return the UDP communication Channel |
61 | */ | 61 | */ |
@@ -98,7 +98,7 @@ public class Client { | |||
98 | } | 98 | } |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Close the Channel. | 101 | * Closes the Channel. |
102 | */ | 102 | */ |
103 | void closeChannel() { | 103 | void closeChannel() { |
104 | try { | 104 | try { |
@@ -109,7 +109,7 @@ public class Client { | |||
109 | } | 109 | } |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Send an action through the Channel. | 112 | * Sends an action through the Channel. |
113 | * | 113 | * |
114 | * @param action action to send | 114 | * @param action action to send |
115 | */ | 115 | */ |
@@ -118,9 +118,9 @@ public class Client { | |||
118 | } | 118 | } |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Receive a GameState through the Channel. | 121 | * Receives a GameState through the Channel. |
122 | * | 122 | * |
123 | * @param block | 123 | * @param block wait for an incoming game state before returning |
124 | * @return the received GameState | 124 | * @return the received GameState |
125 | */ | 125 | */ |
126 | List<Byte> receiveGameState(boolean block) { | 126 | List<Byte> receiveGameState(boolean block) { |
@@ -134,7 +134,7 @@ public class Client { | |||
134 | } | 134 | } |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Send a byte through the Channel. | 137 | * Sends a byte through the Channel. |
138 | * | 138 | * |
139 | * @param b byte to send | 139 | * @param b byte to send |
140 | */ | 140 | */ |
@@ -143,7 +143,7 @@ public class Client { | |||
143 | } | 143 | } |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * Send the content of a buffer. | 146 | * Sends the content of a buffer. |
147 | * | 147 | * |
148 | * @param b buffer containing the bytes to send | 148 | * @param b buffer containing the bytes to send |
149 | */ | 149 | */ |
@@ -156,9 +156,9 @@ public class Client { | |||
156 | } | 156 | } |
157 | 157 | ||
158 | /** | 158 | /** |
159 | * Receive data from the Channel. | 159 | * Receives data from the Channel. |
160 | * | 160 | * |
161 | * @param block | 161 | * @param block wait for an incoming byte before returning |
162 | * @return the received data | 162 | * @return the received data |
163 | */ | 163 | */ |
164 | private Optional<List<Byte>> receive(boolean block) { | 164 | private Optional<List<Byte>> receive(boolean block) { |
@@ -182,7 +182,7 @@ public class Client { | |||
182 | private static class GUI { | 182 | private static class GUI { |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * Build the window. | 185 | * Builds the window. |
186 | * | 186 | * |
187 | * @param content content of the window | 187 | * @param content content of the window |
188 | * @return the frame | 188 | * @return the frame |
@@ -199,7 +199,8 @@ public class Client { | |||
199 | } | 199 | } |
200 | 200 | ||
201 | /** | 201 | /** |
202 | * Attach the keyboard events handler to the component. | 202 | * Attaches the keyboard event handler to the component. |
203 | * | ||
203 | * @param comp component | 204 | * @param comp component |
204 | * @param actionConsumer actionConsumer corresponding to the keyboardEventHandler | 205 | * @param actionConsumer actionConsumer corresponding to the keyboardEventHandler |
205 | */ | 206 | */ |
@@ -225,7 +226,7 @@ public class Client { | |||
225 | } | 226 | } |
226 | 227 | ||
227 | /** | 228 | /** |
228 | * Build and display the GUI. | 229 | * Builds and display the GUI. |
229 | */ | 230 | */ |
230 | public void display() { | 231 | public void display() { |
231 | buildFrame(this.gameComponent); | 232 | buildFrame(this.gameComponent); |
@@ -233,7 +234,7 @@ public class Client { | |||
233 | } | 234 | } |
234 | 235 | ||
235 | /** | 236 | /** |
236 | * Update the displayed GameState. | 237 | * Updates the displayed GameState. |
237 | * | 238 | * |
238 | * @param gs new GameState to be displayed | 239 | * @param gs new GameState to be displayed |
239 | * @param p Player ID corresponding to the client | 240 | * @param p Player ID corresponding to the client |
@@ -245,7 +246,7 @@ public class Client { | |||
245 | } | 246 | } |
246 | 247 | ||
247 | /** | 248 | /** |
248 | * Deserialize the players' IDs. | 249 | * Deserializes the players' IDs. |
249 | * | 250 | * |
250 | * @param b a given byte | 251 | * @param b a given byte |
251 | * @return the Player ID corresponding to the given byte | 252 | * @return the Player ID corresponding to the given byte |
@@ -262,7 +263,7 @@ public class Client { | |||
262 | } | 263 | } |
263 | 264 | ||
264 | /** | 265 | /** |
265 | * Deserialize a received GameState. | 266 | * Deserializes a received GameState. |
266 | * | 267 | * |
267 | * @param b the serialized GameState | 268 | * @param b the serialized GameState |
268 | * @return the deserialized GameState | 269 | * @return the deserialized GameState |
@@ -282,7 +283,7 @@ public class Client { | |||
282 | private final GUI gui; | 283 | private final GUI gui; |
283 | 284 | ||
284 | /** | 285 | /** |
285 | * Instatiates a new client. | 286 | * Instantiates a new client. |
286 | * | 287 | * |
287 | * @param host hostname | 288 | * @param host hostname |
288 | * @param port port | 289 | * @param port port |
@@ -293,7 +294,7 @@ public class Client { | |||
293 | } | 294 | } |
294 | 295 | ||
295 | /** | 296 | /** |
296 | * Run the whole client. | 297 | * Runs the whole client. |
297 | */ | 298 | */ |
298 | public void run() { | 299 | public void run() { |
299 | this.displayGUI(); | 300 | this.displayGUI(); |
@@ -303,7 +304,7 @@ public class Client { | |||
303 | } | 304 | } |
304 | 305 | ||
305 | /** | 306 | /** |
306 | * Display the Graphical User Interface. | 307 | * Displays the Graphical User Interface. |
307 | */ | 308 | */ |
308 | private void displayGUI() { | 309 | private void displayGUI() { |
309 | try { | 310 | try { |
@@ -315,7 +316,7 @@ public class Client { | |||
315 | } | 316 | } |
316 | 317 | ||
317 | /** | 318 | /** |
318 | * Launch the game. | 319 | * Launches the game. |
319 | */ | 320 | */ |
320 | private void runGame() { | 321 | private void runGame() { |
321 | while (true) | 322 | while (true) |
@@ -323,7 +324,7 @@ public class Client { | |||
323 | } | 324 | } |
324 | 325 | ||
325 | /** | 326 | /** |
326 | * Connect to the server and fetch the new GameState. | 327 | * Connects to the server and fetch the new GameState. |
327 | */ | 328 | */ |
328 | private void establishConnection() { | 329 | private void establishConnection() { |
329 | Thread joinThread = new Thread(this::sendJoinRequest); | 330 | Thread joinThread = new Thread(this::sendJoinRequest); |
@@ -333,7 +334,7 @@ public class Client { | |||
333 | } | 334 | } |
334 | 335 | ||
335 | /** | 336 | /** |
336 | * Fetch the new GameState. | 337 | * Fetches the new GameState. |
337 | */ | 338 | */ |
338 | private void updateGameState() { | 339 | private void updateGameState() { |
339 | List<Byte> serializedGameState = this.channel.receiveGameState(true); | 340 | List<Byte> serializedGameState = this.channel.receiveGameState(true); |
@@ -347,7 +348,7 @@ public class Client { | |||
347 |