Start commit 22/02/2022
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"_StorBackEnd/pkg/protocol/repository"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CreateClientMulticast Méthode de construction d'un instance de la stuct ClientMulticast
|
||||
func CreateClientMulticast(address string, second time.Duration) ClientMulticast {
|
||||
func CreateClientMulticast(address string, second time.Duration, repository *repository.ProtocolRepository) ClientMulticast {
|
||||
return ClientMulticast{
|
||||
address: address,
|
||||
second: second,
|
||||
address: address,
|
||||
second: second,
|
||||
repository: repository,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +23,9 @@ type ClientMulticast struct {
|
||||
|
||||
// second Temps en seconde entre chaque ping
|
||||
second time.Duration
|
||||
|
||||
// Repository de protocol permettant de
|
||||
repository *repository.ProtocolRepository
|
||||
}
|
||||
|
||||
// Run Cette méthode démarre une commmunication multicast
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
type ServerUnicast struct {
|
||||
Network string
|
||||
Address string
|
||||
ReqManager protocol.RequestManager
|
||||
ReqManager *protocol.RequestManager
|
||||
}
|
||||
|
||||
func (server ServerUnicast) Run() {
|
||||
@@ -29,12 +29,15 @@ func (server ServerUnicast) Run() {
|
||||
fmt.Printf("Error while accepting client : %s\n", err)
|
||||
return
|
||||
} else {
|
||||
line, err := bufio.NewReader(con).ReadString('\n')
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for { // TODO : Extraire cette partie de code
|
||||
line, err := bufio.NewReader(con).ReadString('\n')
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
server.ReqManager.Execute(line)
|
||||
result := server.ReqManager.Execute(line)
|
||||
con.Write(append([]byte(result), '\n'))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user