Loading go-apps/meep-vis/server/vis.go +0 −94 Original line number Diff line number Diff line Loading @@ -867,72 +867,8 @@ func V2xMsgPublicationPOST(w http.ResponseWriter, r *http.Request) { return } /*** // V2xMsgPub id will be generated sequentially nextV2xMsgPubIdAvailable++ newV2xMsgPubId := nextV2xMsgPubIdAvailable v2xMsgPubIdStr := strconv.Itoa(newV2xMsgPubId) // Save V2xMsgPublication key in the Redis DB _ = rc.JSONSetEntry(baseKey+"V2xMsgPublication:"+v2xMsgPubIdStr, ".", convertV2xMsgPublicationToJson(&v2xMsgPubReq)) subKey := baseKey + "subscriptions:*" // msgTypeAndStdOrgCheck struct is passed to msgTypeAndStdOrg as a pointer // msgTypeAndStdOrgCheck is a struct which has four fields // msgTypeInReq is to get msgType provided in request body // stdOrgInReq is to get stdOrganization provided in request body // callBackReferenceArray is an empty array of the strings // subscriptionLinks is an empty array of the LinkType struct msgTypeAndStdOrg := &msgTypeAndStdOrgCheck{ msgTypeInReq: *v2xMsgPubReq.MsgType, stdOrgInReq: v2xMsgPubReq.StdOrganization, callBackReferenceArray: make([]string, 0), subscriptionLinks: make([]LinkType, 0), } // Retrieve subscription(s) from redis DB one by one _ = rc.ForEachJSONEntry(subKey, compareMsgType, msgTypeAndStdOrg) // end response code w.WriteHeader(http.StatusNoContent) // create V2xMsgNotification body to send notifications v2xMsgNotifBody(v2xMsgPubReq, msgTypeAndStdOrg) ***/ } /* * v2xMsgNotifBody creates ntofication body of type V2xMsgNotification * @param {struct} v2xMsgPubReq is the request body send to /publish_v2x_message endpoint in post request * @param {struct} msgTypeAndStdOrg contains array of _links and callbackReferences of stored subscriptions */ // func v2xMsgNotifBody(v2xMsgPubReq V2xMsgPublication, msgTypeAndStdOrg *msgTypeAndStdOrgCheck) { // var v2xMsgNotification V2xMsgNotification // // make notification body of type V2xMsgNotification // v2xMsgNotification.NotificationType = v2xMsgNotifType // seconds := time.Now().Unix() // nanoseconds := time.Now().UnixNano() // v2xMsgNotification.TimeStamp = &TimeStamp{ // NanoSeconds: int32(nanoseconds), // Seconds: int32(seconds), // } // v2xMsgNotification.StdOrganization = msgTypeAndStdOrg.stdOrgInReq // v2xMsgNotification.MsgType = &msgTypeAndStdOrg.msgTypeInReq // v2xMsgNotification.MsgEncodeFormat = v2xMsgPubReq.MsgEncodeFormat // v2xMsgNotification.MsgContent = v2xMsgPubReq.MsgContent // for i, subLink := range msgTypeAndStdOrg.subscriptionLinks { // v2xMsgNotification.Links = &V2xMsgNotificationLinks{ // Subscription: &LinkType{ // Href: subLink.Href, // }, // } // notifyUrl := msgTypeAndStdOrg.callBackReferenceArray[i] // sendV2xMsgNotification(notifyUrl, v2xMsgNotification) // } // } /* * sendV2xMsgNotification sends notification to the call reference address * @param {string} notifyUrl contains the call reference address Loading Loading @@ -960,36 +896,6 @@ func sendV2xMsgNotification(notifyUrl string, notification V2xMsgNotification) { defer resp.Body.Close() } // func compareMsgType(subKey string, jsonInfo string, msgTypeAndStdOrg interface{}) error { // data := msgTypeAndStdOrg.(*msgTypeAndStdOrgCheck) // if data == nil { // return errors.New("msgTypeAndStdOrg not found") // } // // Retrieve V2xMsgSubscription from DB // var v2xMsgSub V2xMsgSubscription // err := json.Unmarshal([]byte(jsonInfo), &v2xMsgSub) // if err != nil { // return err // } // // compare StdOrganization and MsgType provided in the V2xMsgPublication with the // // StdOrganization and MsgType of the stored subscriptions // if v2xMsgSub.FilterCriteria.StdOrganization == data.stdOrgInReq { // for _, msgType := range v2xMsgSub.FilterCriteria.MsgType { // msgTypeInt, _ := strconv.Atoi(msgType) // if int32(msgTypeInt) == int32(data.msgTypeInReq) { // // append CallbackReference and Links into the list of array to send Notifications on the CallbackReferences // data.callBackReferenceArray = append(data.callBackReferenceArray, v2xMsgSub.CallbackReference) // data.subscriptionLinks = append(data.subscriptionLinks, *v2xMsgSub.Links.Self) // } // } // } // return nil // } // subscriptionsPost is to create subscription at /subscriptions endpoint func subscriptionsPost(w http.ResponseWriter, r *http.Request) { Loading Loading
go-apps/meep-vis/server/vis.go +0 −94 Original line number Diff line number Diff line Loading @@ -867,72 +867,8 @@ func V2xMsgPublicationPOST(w http.ResponseWriter, r *http.Request) { return } /*** // V2xMsgPub id will be generated sequentially nextV2xMsgPubIdAvailable++ newV2xMsgPubId := nextV2xMsgPubIdAvailable v2xMsgPubIdStr := strconv.Itoa(newV2xMsgPubId) // Save V2xMsgPublication key in the Redis DB _ = rc.JSONSetEntry(baseKey+"V2xMsgPublication:"+v2xMsgPubIdStr, ".", convertV2xMsgPublicationToJson(&v2xMsgPubReq)) subKey := baseKey + "subscriptions:*" // msgTypeAndStdOrgCheck struct is passed to msgTypeAndStdOrg as a pointer // msgTypeAndStdOrgCheck is a struct which has four fields // msgTypeInReq is to get msgType provided in request body // stdOrgInReq is to get stdOrganization provided in request body // callBackReferenceArray is an empty array of the strings // subscriptionLinks is an empty array of the LinkType struct msgTypeAndStdOrg := &msgTypeAndStdOrgCheck{ msgTypeInReq: *v2xMsgPubReq.MsgType, stdOrgInReq: v2xMsgPubReq.StdOrganization, callBackReferenceArray: make([]string, 0), subscriptionLinks: make([]LinkType, 0), } // Retrieve subscription(s) from redis DB one by one _ = rc.ForEachJSONEntry(subKey, compareMsgType, msgTypeAndStdOrg) // end response code w.WriteHeader(http.StatusNoContent) // create V2xMsgNotification body to send notifications v2xMsgNotifBody(v2xMsgPubReq, msgTypeAndStdOrg) ***/ } /* * v2xMsgNotifBody creates ntofication body of type V2xMsgNotification * @param {struct} v2xMsgPubReq is the request body send to /publish_v2x_message endpoint in post request * @param {struct} msgTypeAndStdOrg contains array of _links and callbackReferences of stored subscriptions */ // func v2xMsgNotifBody(v2xMsgPubReq V2xMsgPublication, msgTypeAndStdOrg *msgTypeAndStdOrgCheck) { // var v2xMsgNotification V2xMsgNotification // // make notification body of type V2xMsgNotification // v2xMsgNotification.NotificationType = v2xMsgNotifType // seconds := time.Now().Unix() // nanoseconds := time.Now().UnixNano() // v2xMsgNotification.TimeStamp = &TimeStamp{ // NanoSeconds: int32(nanoseconds), // Seconds: int32(seconds), // } // v2xMsgNotification.StdOrganization = msgTypeAndStdOrg.stdOrgInReq // v2xMsgNotification.MsgType = &msgTypeAndStdOrg.msgTypeInReq // v2xMsgNotification.MsgEncodeFormat = v2xMsgPubReq.MsgEncodeFormat // v2xMsgNotification.MsgContent = v2xMsgPubReq.MsgContent // for i, subLink := range msgTypeAndStdOrg.subscriptionLinks { // v2xMsgNotification.Links = &V2xMsgNotificationLinks{ // Subscription: &LinkType{ // Href: subLink.Href, // }, // } // notifyUrl := msgTypeAndStdOrg.callBackReferenceArray[i] // sendV2xMsgNotification(notifyUrl, v2xMsgNotification) // } // } /* * sendV2xMsgNotification sends notification to the call reference address * @param {string} notifyUrl contains the call reference address Loading Loading @@ -960,36 +896,6 @@ func sendV2xMsgNotification(notifyUrl string, notification V2xMsgNotification) { defer resp.Body.Close() } // func compareMsgType(subKey string, jsonInfo string, msgTypeAndStdOrg interface{}) error { // data := msgTypeAndStdOrg.(*msgTypeAndStdOrgCheck) // if data == nil { // return errors.New("msgTypeAndStdOrg not found") // } // // Retrieve V2xMsgSubscription from DB // var v2xMsgSub V2xMsgSubscription // err := json.Unmarshal([]byte(jsonInfo), &v2xMsgSub) // if err != nil { // return err // } // // compare StdOrganization and MsgType provided in the V2xMsgPublication with the // // StdOrganization and MsgType of the stored subscriptions // if v2xMsgSub.FilterCriteria.StdOrganization == data.stdOrgInReq { // for _, msgType := range v2xMsgSub.FilterCriteria.MsgType { // msgTypeInt, _ := strconv.Atoi(msgType) // if int32(msgTypeInt) == int32(data.msgTypeInReq) { // // append CallbackReference and Links into the list of array to send Notifications on the CallbackReferences // data.callBackReferenceArray = append(data.callBackReferenceArray, v2xMsgSub.CallbackReference) // data.subscriptionLinks = append(data.subscriptionLinks, *v2xMsgSub.Links.Self) // } // } // } // return nil // } // subscriptionsPost is to create subscription at /subscriptions endpoint func subscriptionsPost(w http.ResponseWriter, r *http.Request) { Loading