Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8916d7f8b9
BIN
java_pid21340.hprof
Normal file
BIN
java_pid21340.hprof
Normal file
Binary file not shown.
@ -5,18 +5,20 @@ import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* Sends a ping to the server ("CPING") every 2 seconds and checks if it has gotten a pingback.
|
||||
* The actual logging of the pingback (via the gotPingBack boolean) has to be done elsewhere,
|
||||
* depends on how the client receives and parses messages.
|
||||
* Sends a ping to the server ("CPING") every 2 seconds and checks if it has gotten a pingback. The
|
||||
* actual logging of the pingback (via the gotPingBack boolean) has to be done elsewhere, depends on
|
||||
* how the client receives and parses messages.
|
||||
*/
|
||||
public class ClientPinger implements Runnable{
|
||||
private boolean gotPingBack; //should be set to true (via setGotPingBack) as soon as the client gets a pingback.
|
||||
public class ClientPinger implements Runnable {
|
||||
|
||||
private boolean gotPingBack; //should be set to true when client gets a pingback.
|
||||
private boolean isConnected; //set to true unless the ClientPinger detects a connection loss.
|
||||
BufferedWriter out; //the output of this client through which the pings are sent
|
||||
private Socket socket;
|
||||
|
||||
/**
|
||||
* @param socket the socket the Client is connected to which is used to end the thread if the connection is lost.
|
||||
* @param socket the socket the Client is connected to which is used to end the thread if the
|
||||
* connection is lost.
|
||||
* @param out the output through which the pings are sent.
|
||||
*/
|
||||
public ClientPinger(BufferedWriter out, Socket socket) {
|
||||
|
||||
@ -5,18 +5,20 @@ import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* Sends a ping to the client ("SPING") every 2 seconds and checks if it has gotten a pingback.
|
||||
* The actual logging of the pingback (via the gotPingBack boolean) has to be done elsewhere,
|
||||
* depends on how the server receives and parses messages.
|
||||
* Sends a ping to the client ("SPING") every 2 seconds and checks if it has gotten a pingback. The
|
||||
* actual logging of the pingback (via the gotPingBack boolean) has to be done elsewhere, depends on
|
||||
* how the server receives and parses messages.
|
||||
*/
|
||||
public class ServerPinger implements Runnable{
|
||||
public class ServerPinger implements Runnable {
|
||||
|
||||
private boolean gotPingBack; //should be set to true (via setGotPingBack) as soon as the server gets a pingback.
|
||||
private boolean isConnected; //set to true unless the ServerPinger detects a connection loss.
|
||||
BufferedWriter out; //the output of this client through which the pings are sent
|
||||
private Socket socket;
|
||||
|
||||
/**
|
||||
* @param socket the socket the ClientHandler is connected to; used to end the thread if the connection is lost.
|
||||
* @param socket the socket the ClientHandler is connected to; used to end the thread if the
|
||||
* connection is lost.
|
||||
* @param out the output through which the pings are sent.
|
||||
*/
|
||||
public ServerPinger(BufferedWriter out, Socket socket) {
|
||||
|
||||
@ -7,14 +7,14 @@
|
||||
* LEAVG: leave a game
|
||||
* JOING: join a game
|
||||
* VOTEG: ghost voting who to infect
|
||||
* VOTEH: humans voting whos the ghost
|
||||
* QUITS: quit server/ leave servr
|
||||
* VOTEH: humans voting who is the ghost
|
||||
* QUITS: quit server/ leave server
|
||||
* LISTP: list players/clients in session with the Server
|
||||
* CPING: Ping from client to server.
|
||||
*/
|
||||
/**
|
||||
Server Commands:
|
||||
* MSGRS: "Message recieved": Paramaters: a string detailing to the client that and what the server recieved as command.
|
||||
* MSGRS: "Message received": Paramaters: a string detailing to the client that and what the server received as command.
|
||||
* SEROR: Server had an error. (used for debugging)
|
||||
* SPING: Ping from server to client;
|
||||
*/
|
||||
@ -36,7 +36,7 @@ public class Server {
|
||||
|
||||
public void closeServerSocket() {
|
||||
try {
|
||||
if (serverSocket != null){
|
||||
if (serverSocket != null) {
|
||||
serverSocket.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -55,7 +55,7 @@ public class Server {
|
||||
server.startServer();
|
||||
}
|
||||
|
||||
public static void broadcast(String msg){
|
||||
public static void broadcast(String msg) {
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user