StoreBackEnd/cmd/main.go
2022-02-23 13:06:29 +01:00

39 lines
1.1 KiB
Go

package main
import (
"StorBackEnd/pkg/network"
"StorBackEnd/pkg/protocol/managers"
"StorBackEnd/pkg/protocol/repository"
"StorBackEnd/pkg/protocol/rules/readers"
"StorBackEnd/pkg/protocol/rules/writers"
)
const (
MULTICAST_ADDRESS = "226.66.66.1:42500"
MULTICAST_SECOND = 10 // TODO : Changer en 30 secondes
UNICAST_ADDRESS = "0.0.0.0:58000"
)
func main() {
println("StorBackEnd started !")
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(MULTICAST_ADDRESS, MULTICAST_SECOND, protocolRepository)
go multicast.Run()
requestManager := managers.RequestManager{Repository: protocolRepository}
server := network.ServerUnicast{Network: "tcp", Address: UNICAST_ADDRESS, ReqManager: &requestManager}
server.Run()
}