2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
21 "e2mgr/managers/notificationmanager"
25 // RmrService holds an instance of RMR messenger as well as its configuration
26 type RmrServiceReceiver struct {
28 nManager *notificationmanager.NotificationManager
31 // NewRmrService instantiates a new Rmr service instance
32 func NewRmrServiceReceiver(rmrService services.RmrService, nManager *notificationmanager.NotificationManager) *RmrServiceReceiver {
34 return &RmrServiceReceiver{
35 RmrService: rmrService,
40 // ListenAndHandle waits for messages coming from rmr_rcv_msg and sends it to a designated message handler
41 func (r *RmrServiceReceiver) ListenAndHandle() {
44 mbuf, err := (*r.Messenger).RecvMsg()
45 r.Config.Logger.Debugf("#rmr_service_receiver.ListenAndHandle - Going to handle received message: %#v\n", mbuf)
47 // TODO: one mbuf received immediately execute goroutine
49 continue //TODO log error
52 r.nManager.HandleMessage(r.Config.Logger, mbuf, r.RmrResponse)