diff options
Diffstat (limited to 'src/ch/epfl/xblast/server/Server.java')
-rw-r--r-- | src/ch/epfl/xblast/server/Server.java | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/ch/epfl/xblast/server/Server.java b/src/ch/epfl/xblast/server/Server.java index 3f486c6..074b2a7 100644 --- a/src/ch/epfl/xblast/server/Server.java +++ b/src/ch/epfl/xblast/server/Server.java | |||
@@ -34,7 +34,7 @@ public class Server { | |||
34 | public static final byte OBSERVER = -1; | 34 | public static final byte OBSERVER = -1; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Print a log message on the console. | 37 | * Prints a log message on the console. |
38 | * | 38 | * |
39 | * @param message message to be printed | 39 | * @param message message to be printed |
40 | */ | 40 | */ |
@@ -48,7 +48,7 @@ public class Server { | |||
48 | private static class Channel { | 48 | private static class Channel { |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Transform a list of bytes to an array of bytes. | 51 | * Transforms a list of bytes to an array of bytes. |
52 | * | 52 | * |
53 | * @param l the given list of bytes | 53 | * @param l the given list of bytes |
54 | * @return the array built from the given list | 54 | * @return the array built from the given list |
@@ -63,7 +63,7 @@ public class Server { | |||
63 | } | 63 | } |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Create the socket which will be listened. | 66 | * Creates the socket which will be listened to. |
67 | * | 67 | * |
68 | * @param host hostname | 68 | * @param host hostname |
69 | * @param port port to be listened | 69 | * @param port port to be listened |
@@ -77,7 +77,7 @@ public class Server { | |||
77 | } | 77 | } |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Open a UDP channel. | 80 | * Open an UDP channel. |
81 | * | 81 | * |
82 | * @param iface listened socket | 82 | * @param iface listened socket |
83 | * @return a UDP channel | 83 | * @return a UDP channel |
@@ -119,7 +119,7 @@ public class Server { | |||
119 | } | 119 | } |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Close the channel. | 122 | * Closes the channel. |
123 | */ | 123 | */ |
124 | void closeChannel() { | 124 | void closeChannel() { |
125 | try { | 125 | try { |
@@ -130,9 +130,9 @@ public class Server { | |||
130 | } | 130 | } |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * Accept the registration of a new client. | 133 | * Accepts the registration of a new client. |
134 | * | 134 | * |
135 | * @param registrations | 135 | * @param registrations number of expected registrations |
136 | * @return a list of the clients. | 136 | * @return a list of the clients. |
137 | */ | 137 | */ |
138 | List<SocketAddress> acceptRegistrations(int registrations) { | 138 | List<SocketAddress> acceptRegistrations(int registrations) { |
@@ -148,7 +148,7 @@ public class Server { | |||
148 | } | 148 | } |
149 | 149 | ||
150 | /** | 150 | /** |
151 | * Collect actions from the players. | 151 | * Collects actions from the players. |
152 | * | 152 | * |
153 | * @return a list map containing the actions related to each player | 153 | * @return a list map containing the actions related to each player |
154 | */ | 154 | */ |
@@ -166,10 +166,10 @@ public class Server { | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /** | 168 | /** |
169 | * Send data through the socket. | 169 | * Sends data through the socket. |
170 | * | 170 | * |
171 | * @param content data to be send | 171 | * @param content data to be send |
172 | * @param dst recepient of the data | 172 | * @param dst recipient of the data |
173 | */ | 173 | */ |
174 | void send(List<Byte> content, SocketAddress dst) { | 174 | void send(List<Byte> content, SocketAddress dst) { |
175 | try { | 175 | try { |
@@ -181,9 +181,9 @@ public class Server { | |||
181 | } | 181 | } |
182 | 182 | ||
183 | /** | 183 | /** |
184 | * Receive a Byte from the socket. | 184 | * Receives a Byte from the socket. |
185 | * | 185 | * |
186 | * @param block | 186 | * @param block wait for an incoming byte before returning |
187 | * @return an Optional containing the received data | 187 | * @return an Optional containing the received data |
188 | */ | 188 | */ |
189 | private Optional<Map.Entry<SocketAddress, Byte>> receiveByte(boolean block) { | 189 | private Optional<Map.Entry<SocketAddress, Byte>> receiveByte(boolean block) { |
@@ -202,9 +202,9 @@ public class Server { | |||
202 | } | 202 | } |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * Receive a player action from the socket. | 205 | * Receives a player action from the socket. |
206 | * | 206 | * |
207 | * @param block | 207 | * @param block wait for an incoming action before returning |
208 | * @return an Optional containing the received player action | 208 | * @return an Optional containing the received player action |
209 | */ | 209 | */ |
210 | private Optional<Map.Entry<SocketAddress, PlayerAction>> receiveAction(boolean block) { | 210 | private Optional<Map.Entry<SocketAddress, PlayerAction>> receiveAction(boolean block) { |
@@ -218,7 +218,7 @@ public class Server { | |||
218 | } | 218 | } |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * Accept an action from the socket. | 221 | * Accepts an action from the socket. |
222 | * | 222 | * |
223 | * @return the accepted action | 223 | * @return the accepted action |
224 | */ | 224 | */ |
@@ -233,7 +233,7 @@ public class Server { | |||
233 | } | 233 | } |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * Accept the registration of a player | 236 | * Accepts the registration of a player. |
237 | * | 237 | * |
238 | * @return the address of the new player | 238 | * @return the address of the new player |
239 | */ | 239 | */ |
@@ -254,7 +254,7 @@ public class Server { | |||
254 | private final Channel channel; | 254 | private final Channel channel; |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * Required number of player to start a game (up to 4). | 257 | * Required number of player to start a game. |
258 | */ | 258 | */ |
259 | private final int expectedClients; | 259 | private final int expectedClients; |
260 | 260 | ||
@@ -277,7 +277,7 @@ public class Server { | |||
277 | } | 277 | } |
278 | 278 | ||
279 | /** | 279 | /** |
280 | * Run the whole server. | 280 | * Runs the whole server. |
281 | */ | 281 | */ |
282 | public void run() { | 282 | public void run() { |
283 | log("Starting the server..."); | 283 | log("Starting the server..."); |
@@ -287,7 +287,7 @@ public class Server { | |||
287 | } | 287 | } |
288 | 288 | ||
289 | /** | 289 | /** |
290 | * Handle the registration of new clients. | 290 | * Handles the registration of new clients. |
291 | */ | 291 | */ |
292 | private void acceptClientRegistrations() { | 292 | private void acceptClientRegistrations() { |
293 | List<SocketAddress> clients = this.channel.acceptRegistrations(this.expectedClients); | 293 | List<SocketAddress> clients = this.channel.acceptRegistrations(this.expectedClients); |
@@ -296,7 +296,7 @@ public class Server { | |||
296 | } | 296 | } |
297 | 297 | ||
298 | /** | 298 | /** |
299 | * Launch the Game. | 299 | * Launches the Game. |
300 | */ | 300 | */ |
301 | private void runGame() { | 301 | private void runGame() { |
302 | GameState gameState = GameState.DEFAULT_GAME_STATE; | 302 | GameState gameState = GameState.DEFAULT_GAME_STATE; |
@@ -314,7 +314,7 @@ public class Server { | |||
314 | } | 314 | } |
315 | 315 | ||
316 | /** | 316 | /** |
317 | * Update the given GameState to the next tick. | 317 | * Updates the given GameState to the next tick. |
318 | * | 318 | * |
319 | * @param gs the given GameState | 319 | * @param gs the given GameState |
320 | * @return the updated GameState | 320 | * @return the updated GameState |
@@ -325,7 +325,7 @@ public class Server { | |||
325 | } | 325 | } |
326 | 326 | ||
327 | /** | 327 | /** |
328 | * Send the GameState to every player. | 328 | * Sends the GameState to every player. |
329 | * | 329 | * |
330 | * @param gs the GameState to be send. | 330 | * @param gs the GameState to be send. |
331 | */ | 331 | */ |