From 1a188f6bbd4a0bb8f96ce94ad87e666a31332a62 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Tue, 12 Apr 2022 14:26:26 +0200 Subject: [PATCH] Fixed Problem "Empty Messages can be sent" if receiver != * --- .../zhaw/pm2/multichat/client/ClientConnectionHandler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java b/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java index fb57727..22e4ce2 100644 --- a/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java +++ b/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java @@ -202,9 +202,12 @@ public class ClientConnectionHandler implements Runnable { if (state != CONNECTED) throw new ChatProtocolException("Illegal state for message: " + state); Matcher matcher = messagePattern.matcher(messageString); - if (messageString != "" && matcher.find()) { + if (matcher.find()) { String receiver = matcher.group(1); String message = matcher.group(2); + if(message.length() < 1){ + return false; + } if (receiver == null || receiver.isBlank()) receiver = ClientConnectionHandler.USER_ALL; this.sendData(userName, receiver, DATA_TYPE_MESSAGE,message); return true;