+//-------------------------------------------------------------------
+// SUBS CREATE Handling
+//-------------------------------------------------------------------
+func (c *Control) handleSubscriptionCreate(subs *Subscription, parentTrans *Transaction) {
+
+ trans := c.tracker.NewTransaction(subs.GetMeid())
+ subs.WaitTransactionTurn(trans)
+ defer subs.ReleaseTransactionTurn(trans)
+ defer trans.Release()
+
+ xapp.Logger.Debug("SUBS-SubReq: Handling %s parent %s", idstring(trans, subs, nil), parentTrans.String())
+
+ if subs.SubRespMsg != nil {
+ xapp.Logger.Debug("SUBS-SubReq: Handling (immediate response) %s parent %s", idstring(nil, subs, nil), parentTrans.String())
+ parentTrans.SendEvent(subs.SubRespMsg, 0)
+ return
+ }
+
+ event := c.sendE2TSubscriptionRequest(subs, trans, parentTrans)
+ switch themsg := event.(type) {
+ case *e2ap.E2APSubscriptionResponse:
+ subs.SubRespMsg = themsg
+ parentTrans.SendEvent(event, 0)
+ return
+ case *e2ap.E2APSubscriptionFailure:
+ //TODO: Possible delete and one retry for subs req
+ parentTrans.SendEvent(event, 0)
+ default:
+ xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(trans, subs, nil))
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ parentTrans.SendEvent(nil, 0)
+ }
+
+ go c.registry.RemoveFromSubscription(subs, parentTrans, 5*time.Second)
+}
+
+//-------------------------------------------------------------------
+// SUBS DELETE Handling
+//-------------------------------------------------------------------
+func (c *Control) handleSubscriptionDelete(subs *Subscription, parentTrans *Transaction) {
+
+ trans := c.tracker.NewTransaction(subs.GetMeid())
+ subs.WaitTransactionTurn(trans)
+ defer subs.ReleaseTransactionTurn(trans)
+ defer trans.Release()
+
+ xapp.Logger.Debug("SUBS-SubDelReq: Handling %s parent %s", idstring(trans, subs, nil), parentTrans.String())
+
+ event := c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+
+ parentTrans.SendEvent(event, 0)
+ go c.registry.RemoveFromSubscription(subs, parentTrans, 5*time.Second)