- // This is intermediate solution while improving message handling
- //
- packedData, err := c.e2ap.PackSubscriptionRequest(trans.SubReqMsg)
- if err != nil {
- xapp.Logger.Error("SubReq: %s for trans %s", err.Error(), trans)
- c.registry.DelSubscription(subs.Seq)
- trans.Release()
- return
- }
-
- //Optimize and store packed message to be sent (for retransmission). Again owned by subscription?
- trans.Payload = packedData.Buf
- trans.PayloadLen = len(packedData.Buf)
-
- c.rmrSend("SubReq to E2T", subs, trans, packedData.Buf, len(packedData.Buf))
-
- c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.Seq), subReqTime, FirstTry, c.handleSubscriptionRequestTimer)
- xapp.Logger.Debug("SubReq: Debugging trans table = %v", c.tracker.transactionXappTable)
- return
-}
-
-func (c *Control) handleSubscriptionResponse(params *RMRParams) {
- xapp.Logger.Info("SubResp from E2T: %s", params.String())
-
- payloadSeqNum, err := c.e2ap.GetSubscriptionResponseSequenceNumber(params.Payload)
- if err != nil {
- xapp.Logger.Error("SubResp: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
- return
- }
- xapp.Logger.Info("SubResp: Received payloadSeqNum: %v", payloadSeqNum)
-
- subs := c.registry.GetSubscription(payloadSeqNum)
- if subs == nil {
- xapp.Logger.Error("SubResp: Unknown payloadSeqNum. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
- return
- }
-
- trans := subs.GetTransaction()
-
- c.timerMap.StopTimer("RIC_SUB_REQ", int(payloadSeqNum))
-
- responseReceived := trans.CheckResponseReceived()
- if responseReceived == true {
- // Subscription timer already received
- return
+ go c.handleSubscriptionCreate(subs, trans)
+ event, _ := trans.WaitEvent(0) //blocked wait as timeout is handled in subs side
+
+ err = nil
+ if event != nil {
+ switch themsg := event.(type) {
+ case *e2ap.E2APSubscriptionResponse:
+ trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionResponse(themsg)
+ if err == nil {
+ trans.Release()
+ c.rmrSendToXapp("", subs, trans)
+ return
+ }
+ case *e2ap.E2APSubscriptionFailure:
+ trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionFailure(themsg)
+ if err == nil {
+ c.rmrSendToXapp("", subs, trans)
+ }
+ default:
+ break
+ }