2022-02-20 11:33:47 +01:00
|
|
|
package writers
|
2022-02-22 08:47:03 +01:00
|
|
|
|
2022-02-23 13:07:48 +01:00
|
|
|
import "StorBackEnd/pkg/protocol"
|
2022-02-22 08:47:03 +01:00
|
|
|
|
|
|
|
const HelloRuleName = "sbe_hello"
|
|
|
|
|
|
|
|
type HelloRule struct {
|
|
|
|
// Cmd Nom de la règle
|
|
|
|
Cmd string
|
|
|
|
|
|
|
|
// matcher Permet d'extraire de éléments d'une chaine
|
|
|
|
matcher *protocol.RegexMatcher
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateHelloRule Création d'une instance de HelloRule
|
2022-02-22 09:35:44 +01:00
|
|
|
func CreateHelloRule(pattern string) protocol.IProtocolWriter {
|
2022-02-22 08:47:03 +01:00
|
|
|
return &HelloRule{
|
|
|
|
Cmd: HelloRuleName,
|
|
|
|
matcher: protocol.CreateRegexMatcher(pattern),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rule HelloRule) GetCmd() string {
|
|
|
|
return rule.Cmd
|
|
|
|
}
|
|
|
|
|
2022-02-22 09:35:44 +01:00
|
|
|
func (rule HelloRule) Execute(argsData ...string) (string, bool) {
|
|
|
|
return rule.matcher.Build("HELLO", argsData...)
|
2022-02-22 08:47:03 +01:00
|
|
|
}
|