Initial version
[ric-plt/xapp-frame.git] / test / xapp / forwarder.go
diff --git a/test/xapp/forwarder.go b/test/xapp/forwarder.go
new file mode 100755 (executable)
index 0000000..03a3154
--- /dev/null
@@ -0,0 +1,38 @@
+package main
+
+import (
+       "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+)
+
+type Forwarder struct {
+}
+
+func (m Forwarder) Consume(mtype, subId, len int, payload []byte) (err error) {
+       xapp.Logger.Debug("Message received - type=%d subId=%d len=%d", mtype, subId, len)
+
+       // Store data and reply with the same message payload
+       if xapp.Config.GetInt("test.store") != 0 {
+               xapp.Sdl.Store("myKey", payload)
+       }
+
+       mid := xapp.Config.GetInt("test.mtype")
+       if mid != 0 {
+               mtype = mid
+       } else {
+               mtype = mtype + 1
+       }
+
+       sid := xapp.Config.GetInt("test.subId")
+       if sid != 0 {
+               subId = sid
+       }
+
+       if ok := xapp.Rmr.Send(mtype, subId, len, payload); !ok {
+               xapp.Logger.Info("Rmr.Send failed ...")
+       }
+       return
+}
+
+func forwarder() {
+       xapp.Run(Forwarder{})
+}