From 90ef2d450e5a4a0114ce68d6572a934f36e67143 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sat, 26 Feb 2022 13:54:16 +0100 Subject: [PATCH] =?UTF-8?q?-=20HelloRule.java=20:=20Ajout=20constante=20po?= =?UTF-8?q?ur=20position=20des=20donn=C3=A9es=20dans=20le=20tableau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/lightcontainer/protocol/rules/HelloRule.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/lightcontainer/protocol/rules/HelloRule.java b/app/src/main/java/lightcontainer/protocol/rules/HelloRule.java index f4b6c8a..589473e 100644 --- a/app/src/main/java/lightcontainer/protocol/rules/HelloRule.java +++ b/app/src/main/java/lightcontainer/protocol/rules/HelloRule.java @@ -3,8 +3,15 @@ package lightcontainer.protocol.rules; import lightcontainer.protocol.ProtocolReader; public class HelloRule extends ProtocolReader { + private static final String PATTERN = "^HELLO ([A-Za-z0-9]{5,20}) ([0-9]{1,5})\r\n$"; + // Index du domain dans le tableau de donnée + private static final int DOMAIN = 0; + + //Index du port dans le tableau de donnée + private static final int PORT = 1; + public HelloRule() { super(PATTERN); } @@ -12,8 +19,8 @@ public class HelloRule extends ProtocolReader { @Override protected void onExecuted(String... data) { - String domain = data[0]; - String port = data[1]; + String domain = data[DOMAIN]; + String port = data[PORT]; System.out.printf("Règle Hello avec domain=%s et port=%s\n", domain, port); }