Reformat code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
|
||||
session.getBasicRemote()
|
||||
.sendText("Reversed: " + new StringBuilder(message).reverse());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,5 +18,7 @@
|
||||
package samples.websocket.undertow.snake;
|
||||
|
||||
public enum Direction {
|
||||
|
||||
NONE, NORTH, SOUTH, EAST, WEST
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,13 @@ package samples.websocket.undertow.snake;
|
||||
public class Location {
|
||||
|
||||
public int x;
|
||||
|
||||
public int y;
|
||||
|
||||
public static final int GRID_SIZE = 10;
|
||||
|
||||
public static final int PLAYFIELD_HEIGHT = 480;
|
||||
|
||||
public static final int PLAYFIELD_WIDTH = 640;
|
||||
|
||||
public Location(int x, int y) {
|
||||
@@ -74,4 +78,5 @@ public class Location {
|
||||
result = 31 * result + this.y;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -157,4 +157,5 @@ public class Snake {
|
||||
public String getHexColor() {
|
||||
return this.hexColor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -112,4 +112,5 @@ public class SnakeTimer {
|
||||
gameTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ import java.util.Random;
|
||||
public class SnakeUtils {
|
||||
|
||||
public static final int PLAYFIELD_WIDTH = 640;
|
||||
|
||||
public static final int PLAYFIELD_HEIGHT = 480;
|
||||
|
||||
public static final int GRID_SIZE = 10;
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
@@ -30,13 +30,17 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
|
||||
public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||
|
||||
public static final int PLAYFIELD_WIDTH = 640;
|
||||
|
||||
public static final int PLAYFIELD_HEIGHT = 480;
|
||||
|
||||
public static final int GRID_SIZE = 10;
|
||||
|
||||
private static final AtomicInteger snakeIds = new AtomicInteger(0);
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
private final int id;
|
||||
|
||||
private Snake snake;
|
||||
|
||||
public static String getRandomHexColor() {
|
||||
@@ -109,4 +113,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||
SnakeTimer.broadcast(
|
||||
String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user