blob: 63ec16f20df280a39a056c1ace640a85a5367331 [file] [log] [blame]
Mohamed Abukar2e78e422019-06-02 11:45:52 +03001package main
2
3import (
4 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
5)
6
7type Forwarder struct {
8}
9
Mohamed Abukarf11ab7a2019-08-14 16:55:01 +030010func (m Forwarder) Consume(params *xapp.RMRParams) (err error) {
11 xapp.Logger.Debug("Message received - type=%d subId=%d meid=%v xid=%v", params.Mtype, params.SubId, params.Meid, params.Xid)
Mohamed Abukar2e78e422019-06-02 11:45:52 +030012
13 // Store data and reply with the same message payload
14 if xapp.Config.GetInt("test.store") != 0 {
Mohamed Abukarf11ab7a2019-08-14 16:55:01 +030015 xapp.Sdl.Store("myKey", params.Payload)
Mohamed Abukar2e78e422019-06-02 11:45:52 +030016 }
17
18 mid := xapp.Config.GetInt("test.mtype")
19 if mid != 0 {
Mohamed Abukarf11ab7a2019-08-14 16:55:01 +030020 params.Mtype = mid
Mohamed Abukar2e78e422019-06-02 11:45:52 +030021 } else {
Mohamed Abukarf11ab7a2019-08-14 16:55:01 +030022 params.Mtype = params.Mtype + 1
Mohamed Abukar2e78e422019-06-02 11:45:52 +030023 }
24
25 sid := xapp.Config.GetInt("test.subId")
26 if sid != 0 {
Mohamed Abukarf11ab7a2019-08-14 16:55:01 +030027 params.SubId = sid
Mohamed Abukar2e78e422019-06-02 11:45:52 +030028 }
29
Mohamed Abukarf11ab7a2019-08-14 16:55:01 +030030 if ok := xapp.Rmr.SendMsg(params); !ok {
Mohamed Abukar2e78e422019-06-02 11:45:52 +030031 xapp.Logger.Info("Rmr.Send failed ...")
32 }
33 return
34}
35
36func forwarder() {
37 xapp.Run(Forwarder{})
38}