Updates to various TODOs
This commit is contained in:
parent
03d4942552
commit
90728e3833
@ -21,7 +21,6 @@ public class NTtBProtocolParser implements ProtocolParser {
|
|||||||
|
|
||||||
public NTtBProtocolParser(Client caller) {
|
public NTtBProtocolParser(Client caller) {
|
||||||
this.caller = caller;
|
this.caller = caller;
|
||||||
//TODO by far not done!
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String parseMsg(String msg) {
|
public String parseMsg(String msg) {
|
||||||
@ -38,7 +37,7 @@ public class NTtBProtocolParser implements ProtocolParser {
|
|||||||
parsedMsg = buildProtocolMsg(input);
|
parsedMsg = buildProtocolMsg(input);
|
||||||
} catch (EmptyClientInputException e) {
|
} catch (EmptyClientInputException e) {
|
||||||
return e.getExceptionMsg();
|
return e.getExceptionMsg();
|
||||||
//TODO Where to we log this?
|
//TODO Where do we log this?
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsedMsg;
|
return parsedMsg;
|
||||||
@ -56,7 +55,7 @@ public class NTtBProtocolParser implements ProtocolParser {
|
|||||||
int size = input.size();
|
int size = input.size();
|
||||||
for(int i = 1; i < size; i++) {
|
for(int i = 1; i < size; i++) {
|
||||||
s.append("$");
|
s.append("$");
|
||||||
s.append(input.get(i).toLowerCase());
|
s.append(input.get(i).toLowerCase()); //parameters are always lower case (is that good?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s.toString();
|
return s.toString();
|
||||||
|
|||||||
@ -2,4 +2,5 @@ package ch.unibas.dmi.dbis.cs108.Multiplayer.Protocol;
|
|||||||
|
|
||||||
public interface ProtocolDecoder {
|
public interface ProtocolDecoder {
|
||||||
|
|
||||||
|
public String decodeMsg(String msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ public class ClientHandler implements Runnable {
|
|||||||
public static HashSet<ClientHandler> connectedClients = new HashSet<>();
|
public static HashSet<ClientHandler> connectedClients = new HashSet<>();
|
||||||
public static HashSet<ClientHandler> inGameClients = new HashSet<>();
|
public static HashSet<ClientHandler> inGameClients = new HashSet<>();
|
||||||
public static HashSet<ClientHandler> ghostClients = new HashSet<>();
|
public static HashSet<ClientHandler> ghostClients = new HashSet<>();
|
||||||
|
private ClientMsgDecoder clientMsgDecoder = new ClientMsgDecoder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the connecting logik in client-server
|
* Implements the connecting logik in client-server
|
||||||
@ -35,18 +36,21 @@ public class ClientHandler implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
/**
|
||||||
|
* point of contact for client and server.
|
||||||
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
String msg;
|
String msg;
|
||||||
|
String response;
|
||||||
while(socket.isConnected()) {
|
while(socket.isConnected()) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
msg = in.readLine();
|
msg = in.readLine();
|
||||||
if( msg.equalsIgnoreCase("QUIT")){
|
response = clientMsgDecoder.decodeMsg(msg); //The response of the server to the clients message
|
||||||
broadcastMessage("Client: " + clientUserName + " has left the Server");
|
out.write(response);
|
||||||
removeClientHandler();
|
out.newLine();
|
||||||
}
|
out.flush();
|
||||||
broadcastMessage(msg);
|
//TODO if merely an acknowledgement is sent back to the client, how does the client recieve game updates?
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
closeEverything(socket, in, out);
|
closeEverything(socket, in, out);
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
package ch.unibas.dmi.dbis.cs108.Multiplayer.Server;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.Multiplayer.Protocol.ProtocolDecoder;
|
||||||
|
|
||||||
|
public class ClientMsgDecoder implements ProtocolDecoder {
|
||||||
|
@Override
|
||||||
|
public String decodeMsg(String msg) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user