Ajout d'un manager de request, qui reçoit les commandes et renvoient une réponse

This commit is contained in:
Benjamin Lejeune 2022-02-20 11:55:11 +01:00
parent 815da08c8d
commit 7ed4f93dc5
2 changed files with 15 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package network package network
import ( import (
"_StorBackEnd/pkg/protocol"
"bufio" "bufio"
"fmt" "fmt"
"net" "net"
@ -9,6 +10,7 @@ import (
type ServerUnicast struct { type ServerUnicast struct {
Network string Network string
Address string Address string
ReqManager protocol.RequestManager
} }
func (server ServerUnicast) Run() { func (server ServerUnicast) Run() {
@ -27,13 +29,12 @@ func (server ServerUnicast) Run() {
fmt.Printf("Error while accepting client : %s\n", err) fmt.Printf("Error while accepting client : %s\n", err)
return return
} else { } else {
line, err := bufio.NewReader(con).ReadString('\n') line, err := bufio.NewReader(con).ReadString('\n')
if err != nil { if err != nil {
return return
} }
fmt.Printf("MESSAGE : %s\n", line) server.ReqManager.Execute(line)
} }
} }

View File

@ -0,0 +1,10 @@
package protocol
type RequestManager struct {
}
func (receiver RequestManager) Execute(request string) {
// On lis ce que l'on reçoit
// On renvoie la réponse (Comment pour fichier ?)
}