mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Code cleanup
This commit is contained in:
@@ -77,7 +77,6 @@ public enum CHomeUI implements ICDoc, IMenuProvider {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
Singletons.getControl().getForgeMenu().setProvider(this);
|
Singletons.getControl().getForgeMenu().setProvider(this);
|
||||||
|
|
||||||
selectPrevious();
|
selectPrevious();
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
|
|
||||||
|
|
||||||
public class NetServer {
|
public class NetServer {
|
||||||
|
|
||||||
private final Server srv = new Server();
|
private final Server srv = new Server();
|
||||||
private final Set<ClientSocket> _openSockets = new CopyOnWriteArraySet<ClientSocket>();
|
private final Set<ClientSocket> _openSockets = new CopyOnWriteArraySet<ClientSocket>();
|
||||||
|
|
||||||
@@ -42,8 +41,7 @@ public class NetServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class GameServlet extends WebSocketServlet
|
public class GameServlet extends WebSocketServlet {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
|
public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
|
||||||
System.out.printf("Connection from %s recieved%n", request.getRemoteAddr());
|
System.out.printf("Connection from %s recieved%n", request.getRemoteAddr());
|
||||||
@@ -51,13 +49,10 @@ public class NetServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ClientSocket implements WebSocket.OnTextMessage, IClientSocket {
|
||||||
public class ClientSocket implements WebSocket.OnTextMessage, IClientSocket
|
|
||||||
{
|
|
||||||
private Connection _connection;
|
private Connection _connection;
|
||||||
private IConnectionObserver _client;
|
private IConnectionObserver _client;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose(int closeCode, String message) {
|
public void onClose(int closeCode, String message) {
|
||||||
System.out.println("Lost connection: " + closeCode + ", " + message);
|
System.out.println("Lost connection: " + closeCode + ", " + message);
|
||||||
@@ -97,8 +92,7 @@ public class NetServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void listen(int port) {
|
public void listen(int port) {
|
||||||
if (!srv.isStarted())
|
if (!srv.isStarted()) {
|
||||||
{
|
|
||||||
portNumber = port;
|
portNumber = port;
|
||||||
URI serverUri = null;
|
URI serverUri = null;
|
||||||
try {
|
try {
|
||||||
@@ -108,10 +102,10 @@ public class NetServer {
|
|||||||
|
|
||||||
String host = connector.getHost();
|
String host = connector.getHost();
|
||||||
serverUri = new URI(String.format("ws://%s:%d/", host == null ? "localhost" : host ,port));
|
serverUri = new URI(String.format("ws://%s:%d/", host == null ? "localhost" : host ,port));
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Server started @ " + serverUri);
|
System.out.println("Server started @ " + serverUri);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -123,9 +117,9 @@ public class NetServer {
|
|||||||
try {
|
try {
|
||||||
srv.stop();
|
srv.stop();
|
||||||
portNumber = -1;
|
portNumber = -1;
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user