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

Final Push

parent 019c7717
No related branches found
No related tags found
No related merge requests found
package main
/*Programme ayant pour but d'implémenter Gnutella en GO et utilisant REST pour communiquer
Réalisé par : Ivan Rigo et John Jenni
*/
import (
"fmt"
"io/ioutil"
......@@ -33,17 +37,20 @@ var err error
var assignTransM sync.Mutex
var endResult string
// Required Full route to communicate
func getRequest(urlTxt string) {
resp, err := http.Get(urlTxt)
printErr(err)
fmt.Println(resp.Status)
}
// Print the result of the search
func showReq(c *gin.Context) {
fmt.Println(endResult)
c.IndentedJSON(http.StatusOK, endResult)
}
// Start the search
func initReq(c *gin.Context) {
msgId = rand.Intn(100) + data.ID
transmitter = -1
......@@ -65,6 +72,7 @@ func receiveReq(c *gin.Context) {
msgIdInt, err := strconv.Atoi(c.Param("msgId"))
printErr(err)
// msgID aloow to recognize first call of new search
assignTransM.Lock()
if msgId != msgIdInt {
msgId = msgIdInt
......@@ -100,7 +108,7 @@ func receiveReq(c *gin.Context) {
c.Status(http.StatusOK)
}
//Called by child when ressource is find
//Called by child when ressource is found
func foundReq(c *gin.Context) {
if transmitter == -1 {
if endResult == "" {
......
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