Recherche d'un bug d'interface réseaux multicast

This commit is contained in:
2022-03-08 12:01:51 +01:00
parent e9fafd3cd8
commit 30e21ce042
9 changed files with 53 additions and 25 deletions

View File

@@ -1,6 +1,9 @@
package readers
import "StoreBackEnd/pkg/protocol"
import (
"StoreBackEnd/pkg/protocol"
"bufio"
)
// EraseFileRulePrefix Identifiant de cette règle
const EraseFileRulePrefix = "ERASEFILE"
@@ -26,13 +29,13 @@ func (rule EraseFileRule) GetCmd() string {
return rule.Cmd
}
func (rule EraseFileRule) Execute(data string) (string, bool) {
func (rule EraseFileRule) Execute(data string) (string, bool, func(r *bufio.Reader) (string, bool)) {
if rule.Match(data) {
values := rule.matcher.Parse(data)
println(values[1], " est le hash du fichier à supprimer")
return "Parsing : Fichier avec le hash " + values[1] + " supprimé", true
return "Parsing : Fichier avec le hash " + values[1] + " supprimé", true, nil
} else {
return "Parsing : EraseFileRule command incorrecte", false
return "Parsing : EraseFileRule command incorrecte", false, nil
}
}

View File

@@ -1,6 +1,9 @@
package readers
import "StoreBackEnd/pkg/protocol"
import (
"StoreBackEnd/pkg/protocol"
"bufio"
)
// SendFileRulePrefix Rule command prefix
const SendFileRulePrefix = "ffe_sendfile"
@@ -27,19 +30,23 @@ func (rule SendFileRule) GetCmd() string {
}
// Execute the Rule with a string command.
func (rule SendFileRule) Execute(data string) (string, bool) {
func (rule SendFileRule) Execute(data string) (string, bool, func(r *bufio.Reader) (string, bool)) {
if rule.Match(data) { // TODO : cloture this command.
values := rule.matcher.Parse(data)
//callback := func() {
//
//}
//callback()
// print received data
println(values[1], " File Name Hash")
println(values[2], " File Size")
println(values[3], " File Content Hash")
return "SEND_OK\r\n", true
// function callback
callback := func(r *bufio.Reader) (string, bool) {
return "", false
}
return "SEND_OK\r\n", true, callback
} else {
return "jjdjd", false
return "jjdjd", false, nil
}
}