package main import ( "StoreBackEnd/pkg/config" "StoreBackEnd/pkg/network" "StoreBackEnd/pkg/protocol/managers" "StoreBackEnd/pkg/protocol/repository" "StoreBackEnd/pkg/protocol/rules/readers" "StoreBackEnd/pkg/protocol/rules/writers" "time" ) const ( FilePath = "resources/AppConfig.json" ) func main() { println("StoreBackEnd started !") // Loading App config appConfig, err := config.Read(FilePath) if err != nil { println("Impossible de charger la configuration du server : " + err.Error()) return } println("Multicast Address : " + appConfig.MulticastAddress) println("StoreBacked Domain : " + appConfig.Domain) protocolRepository := repository.CreateProtocolRepository() // Création des Writers helloRule := writers.CreateHelloRule("^HELLO ([A-Za-z0-9]{5,20}) ([0-9]{1,5})\r\n$") protocolRepository.AddWriter(&helloRule) // Création des Readers eraseFileRule := readers.CreateEraseFileRule("^ERASEFILE ([A-Za-z0-9.]{50,200})\r\n$") protocolRepository.AddReader(&eraseFileRule) 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() }