Fix bug where message not reset after sending

This commit is contained in:
Tobias Eidelpes 2020-11-11 17:22:24 +01:00
parent 50b3b45866
commit 4edb13e963
2 changed files with 8 additions and 7 deletions

View File

@ -84,12 +84,16 @@ public class ClientConnection implements Runnable {
out.println(mie.getMessage()); out.println(mie.getMessage());
} }
} else if ("subject".equals(userInput.split("\\s+")[0])) { } else if ("subject".equals(userInput.split("\\s+")[0])) {
String subject = userInput.split("\\s+", 1)[1]; String subject = "";
if (userInput.split("\\s+").length > 1)
subject = userInput.split("\\s+", 2)[1];
logger.info("Setting subject to: " + subject); logger.info("Setting subject to: " + subject);
msg.setSubject(subject); msg.setSubject(subject);
out.println("ok"); out.println("ok");
} else if ("data".equals(userInput.split("\\s+")[0])) { } else if ("data".equals(userInput.split("\\s+")[0])) {
String data = userInput.split("\\s+", 2)[1]; String data = "";
if (userInput.split("\\s+").length > 1)
data = userInput.split("\\s+", 2)[1];
logger.info("Setting data to: " + data); logger.info("Setting data to: " + data);
msg.setData(data); msg.setData(data);
out.println("ok"); out.println("ok");
@ -123,8 +127,9 @@ public class ClientConnection implements Runnable {
} }
public void sendMessage() throws MissingInputException { public void sendMessage() throws MissingInputException {
msg.allFieldsSet(); this.msg.allFieldsSet();
TransferServer.Producer producer = new TransferServer.Producer(this.blockingQueue, this.msg); TransferServer.Producer producer = new TransferServer.Producer(this.blockingQueue, this.msg);
new Thread(producer).start(); new Thread(producer).start();
this.msg = new Message();
} }
} }

View File

@ -35,10 +35,6 @@ public class TransferServer implements ITransferServer, Runnable {
* @param out the output stream to write console output to * @param out the output stream to write console output to
*/ */
public TransferServer(String componentId, Config config, InputStream in, PrintStream out) { public TransferServer(String componentId, Config config, InputStream in, PrintStream out) {
Config earthPlanet = new Config("mailbox-earth-planet");
Config univerZe = new Config("mailbox-univer-ze");
mailboxServers.add(earthPlanet);
mailboxServers.add(univerZe);
// TODO parse domains for mailbox servers // TODO parse domains for mailbox servers
this.shell = new Shell(in, out); this.shell = new Shell(in, out);
this.shell.register(this); this.shell.register(this);