Further work on CommandExecuter and adjustments to NightServerProtocol.
This commit is contained in:
parent
8916d7f8b9
commit
46ee78d298
@ -1,96 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
|
||||
<title>Test results - HelloWorldTest</title>
|
||||
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="../js/report.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>HelloWorldTest</h1>
|
||||
<div class="breadcrumbs">
|
||||
<a href="../index.html">all</a> >
|
||||
<a href="../packages/ch.unibas.dmi.dbis.cs108.example.html">ch.unibas.dmi.dbis.cs108.example</a> > HelloWorldTest</div>
|
||||
<div id="summary">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="summaryGroup">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="infoBox" id="tests">
|
||||
<div class="counter">1</div>
|
||||
<p>tests</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="failures">
|
||||
<div class="counter">0</div>
|
||||
<p>failures</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="ignored">
|
||||
<div class="counter">0</div>
|
||||
<p>ignored</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="duration">
|
||||
<div class="counter">0.013s</div>
|
||||
<p>duration</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox success" id="successRate">
|
||||
<div class="percent">100%</div>
|
||||
<p>successful</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="tabs">
|
||||
<ul class="tabLinks">
|
||||
<li>
|
||||
<a href="#tab0">Tests</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="tab0" class="tab">
|
||||
<h2>Tests</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Test</th>
|
||||
<th>Duration</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td class="success">testMain()</td>
|
||||
<td class="success">0.013s</td>
|
||||
<td class="success">passed</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<p>
|
||||
<div>
|
||||
<label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines
|
||||
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
|
||||
</label>
|
||||
</div>Generated by
|
||||
<a href="http://www.gradle.org">Gradle 6.9.2</a> at 26.03.2022, 12:19:23</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -17,4 +17,5 @@
|
||||
* 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;
|
||||
* NOCMD: Co command found.
|
||||
*/
|
||||
@ -21,7 +21,7 @@ public class NightTrainProtocol {
|
||||
//Client Commands
|
||||
CRTGM, CHATA, CHATW, CHATG, LEAVG, JOING, VOTEG, QUITS, LISTP, CUSRN,CPING,
|
||||
//Server Responses
|
||||
MSGRS, SEROR, SPING;
|
||||
MSGRS, SEROR, SPING, NOCMD
|
||||
}
|
||||
|
||||
private static HashMap<String, NTtBCommands> initializeMapping(){
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.server.cmd.methods;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.protocol.NTtBFormatMsg;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.protocol.NightTrainProtocol.NTtBCommands;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This Class implements actually acting on the clients
|
||||
* messages.
|
||||
* This Class implements actually acting on the clients messages.
|
||||
*/
|
||||
public class CommandExecuter {
|
||||
|
||||
ClientHandler caller;
|
||||
private ClientHandler caller;
|
||||
private static String msgPrefix = "SERVER: ";
|
||||
|
||||
public static void execute(NTtBFormatMsg msg) {
|
||||
public void execute(NTtBFormatMsg msg) {
|
||||
switch (msg.getCommand()) {
|
||||
case CRTGM:
|
||||
break;
|
||||
@ -55,19 +56,55 @@ public class CommandExecuter {
|
||||
case SPING:
|
||||
pongC();
|
||||
break;
|
||||
default:
|
||||
this.noCommand();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void wisper(String[] parameters) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void changeNickname(String[] parameters) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void quitServer() {
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void pongC() {
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void pongS() {
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void noCommand() {
|
||||
try {
|
||||
caller.getOut().write(msgPrefix + String.valueOf(NTtBCommands.NOCMD));
|
||||
} catch (IOException e) {
|
||||
System.out.println("IOException in noCommand() in CommandExecuter.java");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* boradcast chat message to everyone
|
||||
* @param parameters should only have one entry i.e.
|
||||
* parameters.length == 1
|
||||
* should be true;
|
||||
*
|
||||
* @param parameters should only have one entry i.e. parameters.length == 1 should be true;
|
||||
*/
|
||||
private static void broadcastClientMsg(String[] parameters) throws IOException {
|
||||
for(ClientHandler clients: ClientHandler.connectedClients) {
|
||||
private static void broadcastClientMsg(String[] parameters) {
|
||||
try {
|
||||
for (ClientHandler clients : ClientHandler.connectedClients) {
|
||||
clients.getOut().write(parameters[0]);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println("IOEXCEPTION in CommandExecuter.java at broadcastClientMsg");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user