Ajout des 3règles SendFileRule.go, SendOkRule.go, SendErrorRule.go et corrections de bugs mineurs.
This commit is contained in:
30
cmd/main.go
30
cmd/main.go
@@ -29,19 +29,43 @@ func main() {
|
||||
|
||||
protocolRepository := repository.CreateProtocolRepository()
|
||||
|
||||
// Création des Writers
|
||||
/**
|
||||
===== Init all Write here =====
|
||||
*/
|
||||
// Creation of the HelloRule
|
||||
helloRule := writers.CreateHelloRule("^HELLO ([A-Za-z0-9]{5,20}) ([0-9]{1,5})\r\n$")
|
||||
protocolRepository.AddWriter(&helloRule)
|
||||
|
||||
// Création des Readers
|
||||
// Creation of the SendOkRule
|
||||
sendOkRule := writers.CreateSendOkRule("^SEND_OK\n$")
|
||||
protocolRepository.AddWriter(&sendOkRule)
|
||||
|
||||
// Creation of the SendErrorRule
|
||||
sendErrorRule := writers.CreateSendOkRule("^SEND_ERROR\n$")
|
||||
protocolRepository.AddWriter(&sendErrorRule)
|
||||
|
||||
/**
|
||||
===== Init all Reader here =====
|
||||
*/
|
||||
// Creation of the EraseFileRule
|
||||
eraseFileRule := readers.CreateEraseFileRule("^ERASEFILE ([A-Za-z0-9.]{50,200})\r\n$")
|
||||
protocolRepository.AddReader(&eraseFileRule)
|
||||
|
||||
// Creation of the SendFileRule
|
||||
sendFileRule := readers.CreateSendFileRule("^SENDFILE ([A-Za-z0-9.]{50,200} [0-9]{1,10} [A-Za-z0-9.]{50,200})\r\n$")
|
||||
protocolRepository.AddReader(&sendFileRule)
|
||||
|
||||
// Create a Multicast Client & run it
|
||||
multicast := network.CreateClientMulticast(appConfig.MulticastAddress, appConfig.Domain, appConfig.UnicastPort, time.Duration(appConfig.MulticastSecond), protocolRepository)
|
||||
go multicast.Run()
|
||||
|
||||
requestManager := managers.RequestManager{Repository: protocolRepository}
|
||||
|
||||
server := network.ServerUnicast{Network: "tcp", Port: appConfig.UnicastPort, ReqManager: &requestManager}
|
||||
server.Run()
|
||||
server.Run() // TODO : -> pourquoi ne pas partir dans un thread ici.
|
||||
|
||||
//reader := bufio.NewReader(os.Stdin) TODO ne pas oublier ici de mettre en place un point de sortie pour le programme.
|
||||
//fmt.Print("Type Enter to quite: ")
|
||||
//cmd, _ := reader.ReadString('\n')
|
||||
//println(cmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user