Skip to content
Snippets Groups Projects
Commit 47ff679a authored by ivan.rigo's avatar ivan.rigo
Browse files

Need fix Ham p4

parent 0f6607bf
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,15 @@ func initReq(c *gin.Context) {
msgId = rand.Intn(100)
parent = -1
printErr(err)
for _, x := range arrFile {
if x == c.Param("ressource") {
if !foundRsc {
fmt.Println("Ressource exist in Client")
}
foundRsc = true
break
}
}
for i := 0; i < len(albums); i++ {
if albums[i].ID == idServ {
for j := 0; j < len(albums[i].Neighb); j++ {
......@@ -70,7 +79,7 @@ func receiveReq(c *gin.Context) {
for _, x := range arrFile {
if x == c.Param("ressource") {
if !foundRsc {
go sendFound(c.Param("ressource"))
go sendFound(c.Param("ressource"), idServ)
}
foundRsc = true
break
......@@ -97,13 +106,18 @@ func receiveReq(c *gin.Context) {
//Called by child when ressource is find
func foundReq(c *gin.Context) {
finderNb, err := strconv.Atoi(c.Param("finder"))
printErr(err)
portFinder := strconv.Itoa(basePort + finderNb)
if parent == -1 {
fmt.Println("Ressource found ")
fmt.Println("Instance of " + c.Param("ressource") + " found in " + portFinder)
} else {
sendFound(c.Param("ressource"), c.Param("finder"))
}
}
func sendFound(ressource string) {
resp, err := http.Get("http://localhost:" + strconv.Itoa(basePort+parent) + "/foundReq/" + idServ + "/" + ressource)
func sendFound(ressource string, finder string) {
resp, err := http.Get("http://localhost:" + strconv.Itoa(basePort+parent) + "/foundReq/" + finder + "/" + ressource)
printErr(err)
fmt.Println(resp.Status)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment