Loading go-apps/meep-loc-serv/server/loc-serv.go +114 −80 Original line number Diff line number Diff line Loading @@ -1117,13 +1117,13 @@ func checkNotificationAreaCircle(addressToCheck string) { //check all that applies for subsId, areaCircleCheck := range areaCircleSubscriptionMap { if areaCircleCheck != nil && areaCircleCheck.Subscription != nil { if areaCircleCheck.Subscription.Count == 0 || (areaCircleCheck.Subscription.Count != 0 && areaCircleCheck.NbNotificationsSent < areaCircleCheck.Subscription.Count) { if !areaCircleCheck.NotificationCheckReady { continue } // if areaCircleCheck.Subscription.Count == 0 || (areaCircleCheck.Subscription.Count != 0 && areaCircleCheck.NbNotificationsSent < areaCircleCheck.Subscription.Count) { // if !areaCircleCheck.NotificationCheckReady { // continue // } //loop through every reference address for _, addr := range areaCircleCheck.Subscription.Address { for _, addr := range areaCircleCheck.Subscription.AddressList { if addr != addressToCheck { continue } Loading @@ -1132,9 +1132,9 @@ func checkNotificationAreaCircle(addressToCheck string) { } //check if address is already inside the area or not based on the subscription var withinRangeParam gisClient.TargetRange withinRangeParam.Latitude = areaCircleCheck.Subscription.Latitude withinRangeParam.Longitude = areaCircleCheck.Subscription.Longitude withinRangeParam.Radius = areaCircleCheck.Subscription.Radius withinRangeParam.Latitude = areaCircleCheck.Subscription.AreaDefine.Points[0].Latitude withinRangeParam.Longitude = areaCircleCheck.Subscription.AreaDefine.Points[0].Longitude withinRangeParam.Radius = float32(areaCircleCheck.Subscription.AreaDefine.Radius) withinRangeResp, httpResp, err := gisAppClient.GeospatialDataApi.GetWithinRangeByName(context.TODO(), addr, withinRangeParam) if err != nil { Loading @@ -1150,14 +1150,14 @@ func checkNotificationAreaCircle(addressToCheck string) { } } //check if there is a change var event EnteringLeavingCriteria var event LocationEventType if withinRangeResp.Within { if areaCircleCheck.AddrInArea[addr] { //no change continue } else { areaCircleCheck.AddrInArea[addr] = true event = ENTERING_EnteringLeavingCriteria event = ENTERING_AREA_EVENT } } else { if !areaCircleCheck.AddrInArea[addr] { Loading @@ -1165,22 +1165,21 @@ func checkNotificationAreaCircle(addressToCheck string) { continue } else { areaCircleCheck.AddrInArea[addr] = false event = LEAVING_EnteringLeavingCriteria event = LEAVING_AREA_EVENT } } //no tracking this event, stop looking for this UE if *areaCircleCheck.Subscription.EnteringLeavingCriteria != event { if !contains(areaCircleCheck.Subscription.LocationEventCriteria, event) { continue } subsIdStr := strconv.Itoa(subsId) var areaCircleNotif SubscriptionNotification areaCircleNotif.EnteringLeavingCriteria = areaCircleCheck.Subscription.EnteringLeavingCriteria areaCircleNotif.IsFinalNotification = false areaCircleNotif.Link = areaCircleCheck.Subscription.Link var terminalLocationList []TerminalLocation var terminalLocation TerminalLocation terminalLocation.Address = addr var areaCircleNotif UserAreaNotification areaCircleNotif.UserLocationEvent = areaCircleCheck.Subscription.LocationEventCriteria // areaCircleNotif.IsFinalNotification = false areaCircleNotif.Links = areaCircleCheck.Subscription.Links // var terminalLocationList []TerminalLocation // var terminalLocation TerminalLocation areaCircleNotif.Address = addr var locationInfo LocationInfo locationInfo.Latitude = nil locationInfo.Latitude = append(locationInfo.Latitude, withinRangeResp.SrcLatitude) Loading @@ -1191,26 +1190,41 @@ func checkNotificationAreaCircle(addressToCheck string) { var timestamp TimeStamp timestamp.Seconds = int32(seconds) locationInfo.Timestamp = ×tamp terminalLocation.CurrentLocation = &locationInfo retrievalStatus := RETRIEVED_RetrievalStatus terminalLocation.LocationRetrievalStatus = &retrievalStatus terminalLocationList = append(terminalLocationList, terminalLocation) // terminalLocation.CurrentLocation = &locationInfo // retrievalStatus := RETRIEVED_RetrievalStatus // terminalLocation.LocationRetrievalStatus = &retrievalStatus // terminalLocationList = append(terminalLocationList, terminalLocation) areaCircleNotif.LocationInfo = &locationInfo areaCircleNotif.TerminalLocation = terminalLocationList // areaCircleNotif.TerminalLocation = terminalLocationList areaCircleNotif.CallbackData = areaCircleCheck.Subscription.CallbackReference.CallbackData var inlineCircleSubscriptionNotification InlineSubscriptionNotification inlineCircleSubscriptionNotification.SubscriptionNotification = &areaCircleNotif var inlineCircleSubscriptionNotification InlineUserAreaNotification inlineCircleSubscriptionNotification.UserAreaNotification = &areaCircleNotif areaCircleCheck.NbNotificationsSent++ sendSubscriptionNotification(areaCircleCheck.Subscription.CallbackReference.NotifyURL, inlineCircleSubscriptionNotification) log.Info("Area Circle Notification" + "(" + subsIdStr + ") For " + addr + " when " + string(*areaCircleCheck.Subscription.EnteringLeavingCriteria) + " area") areaCircleSubscriptionMap[subsId].NextTts = areaCircleCheck.Subscription.Frequency areaCircleSubscriptionMap[subsId].NotificationCheckReady = false } sendSubscriptionNotification5(areaCircleCheck.Subscription.CallbackReference.NotifyURL, inlineCircleSubscriptionNotification) // Iterate over LocationEventCriteria and concatenate its values // var eventCriteria []string // for _, criteria := range areaCircleCheck.Subscription.LocationEventCriteria { // eventCriteria = append(eventCriteria, string(criteria)) // } // criteriaStr := strings.Join(eventCriteria, ", ") log.Info("Area Circle Notification" + "(" + subsIdStr + ") For " + addr + " when " + " area") // areaCircleSubscriptionMap[subsId].NextTts = areaCircleCheck.Subscription.Frequency // areaCircleSubscriptionMap[subsId].NotificationCheckReady = false } } } } // } func contains(s []LocationEventType, str LocationEventType) bool { for _, v := range s { if v == str { return true } } return false } func checkNotificationPeriodicTrigger1() { //only check if there is at least one subscription mutex.Lock() Loading Loading @@ -1849,6 +1863,26 @@ func sendSubscriptionNotification(notifyUrl string, notification InlineSubscript met.ObserveNotification(sandboxName, serviceName, notifSubscription, notifyUrl, resp, duration) defer resp.Body.Close() } func sendSubscriptionNotification5(notifyUrl string, notification InlineUserAreaNotification) { startTime := time.Now() jsonNotif, err := json.Marshal(notification) if err != nil { log.Error(err) return } resp, err := http.Post(notifyUrl, "application/json", bytes.NewBuffer(jsonNotif)) duration := float64(time.Since(startTime).Microseconds()) / 1000.0 _ = httpLog.LogNotification(notifyUrl, "POST", "", "", string(jsonNotif), resp, startTime) if err != nil { log.Error(err) met.ObserveNotification(sandboxName, serviceName, notifSubscription, notifyUrl, nil, duration) return } met.ObserveNotification(sandboxName, serviceName, notifSubscription, notifyUrl, resp, duration) defer resp.Body.Close() } func checkNotificationRegisteredZones1(oldZoneId string, newZoneId string, oldApId string, newApId string, userId string) { mutex.Lock() defer mutex.Unlock() Loading Loading @@ -5608,7 +5642,7 @@ func areaCircleReInit() { var areaCircleList NotificationSubscriptionList keyName := baseKey + typeAreaCircleSubscription + "*" _ = rc.ForEachJSONEntry(keyName, populateAreaCircleList, &areaCircleList) _ = rc.ForEachJSONEntry(keyName, populateUserAreaList, &areaCircleList) maxAreaCircleSubscriptionId := 0 mutex.Lock() Loading go-apps/meep-loc-serv/server/model_user_area_notification.go +3 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ package server type UserAreaNotification struct { CallbackData string `json:"callbackData,omitempty"` Links *Links `json:"_links"` // Address of user (e.g. ‘sip’ URI, ‘tel’ URI, ‘acr’ URI). Address string `json:"address"` Loading @@ -24,5 +25,5 @@ type UserAreaNotification struct { TimeStamp *TimeStamp `json:"timeStamp,omitempty"` UserLocationEvent *LocationEventType `json:"userLocationEvent"` UserLocationEvent []LocationEventType `json:"userLocationEvent"` } Loading
go-apps/meep-loc-serv/server/loc-serv.go +114 −80 Original line number Diff line number Diff line Loading @@ -1117,13 +1117,13 @@ func checkNotificationAreaCircle(addressToCheck string) { //check all that applies for subsId, areaCircleCheck := range areaCircleSubscriptionMap { if areaCircleCheck != nil && areaCircleCheck.Subscription != nil { if areaCircleCheck.Subscription.Count == 0 || (areaCircleCheck.Subscription.Count != 0 && areaCircleCheck.NbNotificationsSent < areaCircleCheck.Subscription.Count) { if !areaCircleCheck.NotificationCheckReady { continue } // if areaCircleCheck.Subscription.Count == 0 || (areaCircleCheck.Subscription.Count != 0 && areaCircleCheck.NbNotificationsSent < areaCircleCheck.Subscription.Count) { // if !areaCircleCheck.NotificationCheckReady { // continue // } //loop through every reference address for _, addr := range areaCircleCheck.Subscription.Address { for _, addr := range areaCircleCheck.Subscription.AddressList { if addr != addressToCheck { continue } Loading @@ -1132,9 +1132,9 @@ func checkNotificationAreaCircle(addressToCheck string) { } //check if address is already inside the area or not based on the subscription var withinRangeParam gisClient.TargetRange withinRangeParam.Latitude = areaCircleCheck.Subscription.Latitude withinRangeParam.Longitude = areaCircleCheck.Subscription.Longitude withinRangeParam.Radius = areaCircleCheck.Subscription.Radius withinRangeParam.Latitude = areaCircleCheck.Subscription.AreaDefine.Points[0].Latitude withinRangeParam.Longitude = areaCircleCheck.Subscription.AreaDefine.Points[0].Longitude withinRangeParam.Radius = float32(areaCircleCheck.Subscription.AreaDefine.Radius) withinRangeResp, httpResp, err := gisAppClient.GeospatialDataApi.GetWithinRangeByName(context.TODO(), addr, withinRangeParam) if err != nil { Loading @@ -1150,14 +1150,14 @@ func checkNotificationAreaCircle(addressToCheck string) { } } //check if there is a change var event EnteringLeavingCriteria var event LocationEventType if withinRangeResp.Within { if areaCircleCheck.AddrInArea[addr] { //no change continue } else { areaCircleCheck.AddrInArea[addr] = true event = ENTERING_EnteringLeavingCriteria event = ENTERING_AREA_EVENT } } else { if !areaCircleCheck.AddrInArea[addr] { Loading @@ -1165,22 +1165,21 @@ func checkNotificationAreaCircle(addressToCheck string) { continue } else { areaCircleCheck.AddrInArea[addr] = false event = LEAVING_EnteringLeavingCriteria event = LEAVING_AREA_EVENT } } //no tracking this event, stop looking for this UE if *areaCircleCheck.Subscription.EnteringLeavingCriteria != event { if !contains(areaCircleCheck.Subscription.LocationEventCriteria, event) { continue } subsIdStr := strconv.Itoa(subsId) var areaCircleNotif SubscriptionNotification areaCircleNotif.EnteringLeavingCriteria = areaCircleCheck.Subscription.EnteringLeavingCriteria areaCircleNotif.IsFinalNotification = false areaCircleNotif.Link = areaCircleCheck.Subscription.Link var terminalLocationList []TerminalLocation var terminalLocation TerminalLocation terminalLocation.Address = addr var areaCircleNotif UserAreaNotification areaCircleNotif.UserLocationEvent = areaCircleCheck.Subscription.LocationEventCriteria // areaCircleNotif.IsFinalNotification = false areaCircleNotif.Links = areaCircleCheck.Subscription.Links // var terminalLocationList []TerminalLocation // var terminalLocation TerminalLocation areaCircleNotif.Address = addr var locationInfo LocationInfo locationInfo.Latitude = nil locationInfo.Latitude = append(locationInfo.Latitude, withinRangeResp.SrcLatitude) Loading @@ -1191,26 +1190,41 @@ func checkNotificationAreaCircle(addressToCheck string) { var timestamp TimeStamp timestamp.Seconds = int32(seconds) locationInfo.Timestamp = ×tamp terminalLocation.CurrentLocation = &locationInfo retrievalStatus := RETRIEVED_RetrievalStatus terminalLocation.LocationRetrievalStatus = &retrievalStatus terminalLocationList = append(terminalLocationList, terminalLocation) // terminalLocation.CurrentLocation = &locationInfo // retrievalStatus := RETRIEVED_RetrievalStatus // terminalLocation.LocationRetrievalStatus = &retrievalStatus // terminalLocationList = append(terminalLocationList, terminalLocation) areaCircleNotif.LocationInfo = &locationInfo areaCircleNotif.TerminalLocation = terminalLocationList // areaCircleNotif.TerminalLocation = terminalLocationList areaCircleNotif.CallbackData = areaCircleCheck.Subscription.CallbackReference.CallbackData var inlineCircleSubscriptionNotification InlineSubscriptionNotification inlineCircleSubscriptionNotification.SubscriptionNotification = &areaCircleNotif var inlineCircleSubscriptionNotification InlineUserAreaNotification inlineCircleSubscriptionNotification.UserAreaNotification = &areaCircleNotif areaCircleCheck.NbNotificationsSent++ sendSubscriptionNotification(areaCircleCheck.Subscription.CallbackReference.NotifyURL, inlineCircleSubscriptionNotification) log.Info("Area Circle Notification" + "(" + subsIdStr + ") For " + addr + " when " + string(*areaCircleCheck.Subscription.EnteringLeavingCriteria) + " area") areaCircleSubscriptionMap[subsId].NextTts = areaCircleCheck.Subscription.Frequency areaCircleSubscriptionMap[subsId].NotificationCheckReady = false } sendSubscriptionNotification5(areaCircleCheck.Subscription.CallbackReference.NotifyURL, inlineCircleSubscriptionNotification) // Iterate over LocationEventCriteria and concatenate its values // var eventCriteria []string // for _, criteria := range areaCircleCheck.Subscription.LocationEventCriteria { // eventCriteria = append(eventCriteria, string(criteria)) // } // criteriaStr := strings.Join(eventCriteria, ", ") log.Info("Area Circle Notification" + "(" + subsIdStr + ") For " + addr + " when " + " area") // areaCircleSubscriptionMap[subsId].NextTts = areaCircleCheck.Subscription.Frequency // areaCircleSubscriptionMap[subsId].NotificationCheckReady = false } } } } // } func contains(s []LocationEventType, str LocationEventType) bool { for _, v := range s { if v == str { return true } } return false } func checkNotificationPeriodicTrigger1() { //only check if there is at least one subscription mutex.Lock() Loading Loading @@ -1849,6 +1863,26 @@ func sendSubscriptionNotification(notifyUrl string, notification InlineSubscript met.ObserveNotification(sandboxName, serviceName, notifSubscription, notifyUrl, resp, duration) defer resp.Body.Close() } func sendSubscriptionNotification5(notifyUrl string, notification InlineUserAreaNotification) { startTime := time.Now() jsonNotif, err := json.Marshal(notification) if err != nil { log.Error(err) return } resp, err := http.Post(notifyUrl, "application/json", bytes.NewBuffer(jsonNotif)) duration := float64(time.Since(startTime).Microseconds()) / 1000.0 _ = httpLog.LogNotification(notifyUrl, "POST", "", "", string(jsonNotif), resp, startTime) if err != nil { log.Error(err) met.ObserveNotification(sandboxName, serviceName, notifSubscription, notifyUrl, nil, duration) return } met.ObserveNotification(sandboxName, serviceName, notifSubscription, notifyUrl, resp, duration) defer resp.Body.Close() } func checkNotificationRegisteredZones1(oldZoneId string, newZoneId string, oldApId string, newApId string, userId string) { mutex.Lock() defer mutex.Unlock() Loading Loading @@ -5608,7 +5642,7 @@ func areaCircleReInit() { var areaCircleList NotificationSubscriptionList keyName := baseKey + typeAreaCircleSubscription + "*" _ = rc.ForEachJSONEntry(keyName, populateAreaCircleList, &areaCircleList) _ = rc.ForEachJSONEntry(keyName, populateUserAreaList, &areaCircleList) maxAreaCircleSubscriptionId := 0 mutex.Lock() Loading
go-apps/meep-loc-serv/server/model_user_area_notification.go +3 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ package server type UserAreaNotification struct { CallbackData string `json:"callbackData,omitempty"` Links *Links `json:"_links"` // Address of user (e.g. ‘sip’ URI, ‘tel’ URI, ‘acr’ URI). Address string `json:"address"` Loading @@ -24,5 +25,5 @@ type UserAreaNotification struct { TimeStamp *TimeStamp `json:"timeStamp,omitempty"` UserLocationEvent *LocationEventType `json:"userLocationEvent"` UserLocationEvent []LocationEventType `json:"userLocationEvent"` }