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) {
|
||||
this.caller = caller;
|
||||
//TODO by far not done!
|
||||
}
|
||||
@Override
|
||||
public String parseMsg(String msg) {
|
||||
@ -38,7 +37,7 @@ public class NTtBProtocolParser implements ProtocolParser {
|
||||
parsedMsg = buildProtocolMsg(input);
|
||||
} catch (EmptyClientInputException e) {
|
||||
return e.getExceptionMsg();
|
||||
//TODO Where to we log this?
|
||||
//TODO Where do we log this?
|
||||
}
|
||||
|
||||
return parsedMsg;
|
||||
@ -56,7 +55,7 @@ public class NTtBProtocolParser implements ProtocolParser {
|
||||
int size = input.size();
|
||||
for(int i = 1; i < size; i++) {
|
||||
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();
|
||||
|
||||
@ -2,4 +2,5 @@ package ch.unibas.dmi.dbis.cs108.Multiplayer.Protocol;
|
||||
|
||||
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> inGameClients = new HashSet<>();
|
||||
public static HashSet<ClientHandler> ghostClients = new HashSet<>();
|
||||
private ClientMsgDecoder clientMsgDecoder = new ClientMsgDecoder();
|
||||
|
||||
/**
|
||||
* Implements the connecting logik in client-server
|
||||
@ -35,18 +36,21 @@ public class ClientHandler implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* point of contact for client and server.
|
||||
*/
|
||||
public void run() {
|
||||
String msg;
|
||||
|
||||
String response;
|
||||
while(socket.isConnected()) {
|
||||
try {
|
||||
|
||||
msg = in.readLine();
|
||||
if( msg.equalsIgnoreCase("QUIT")){
|
||||
broadcastMessage("Client: " + clientUserName + " has left the Server");
|
||||
removeClientHandler();
|
||||
}
|
||||
broadcastMessage(msg);
|
||||
response = clientMsgDecoder.decodeMsg(msg); //The response of the server to the clients message
|
||||
out.write(response);
|
||||
out.newLine();
|
||||
out.flush();
|
||||
//TODO if merely an acknowledgement is sent back to the client, how does the client recieve game updates?
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
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