Example #1
0
func initRoutes() {
	user := user.User{}
	user.InitUser()

	session := session.Session{}
	session.InitSession()

	place := place.Place{}
	place.InitPlace()

	post := post.Post{}
	post.InitPost()

	like := like.Like{}
	like.InitLike()

	talk := talk.Talk{}
	talk.InitTalk()

	match := match.Match{}
	match.InitMatch()

	notification := notification.Notification{}
	notification.InitNotification()

	message := message.Message{}
	message.InitMessage()

	fs := http.FileServer(http.Dir("./assets"))
	http.Handle("/Images/", fs)
}
Example #2
0
func websocketHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Println("In : ")
	user := user.User{}
	user.Token = getParamURI(r.URL.RequestURI(), "token")
	if user.GetUserByToken() == false {
		errors := api.Error{}
		errors.ListErrors = append(errors.ListErrors, "Session doesn't exist")
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusNotAcceptable)
		json.NewEncoder(w).Encode(errors)
		return
	}
	if checkIfUserIsInArray(user.Id) == true {
		errors := api.Error{}
		errors.ListErrors = append(errors.ListErrors, "Websocket session exist.")
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusNotAcceptable)
		json.NewEncoder(w).Encode(errors)
		return
	} else {
		go addUserInArray(user.Id)
	}
	fmt.Println("User :"******"break")
				break
			}
		}
		socket.Close()
		fmt.Println("Out : ")
		removeUserInArray(user.Id)
	}()
}