2 ==================================================================================
3 Copyright (c) 2020 AT&T Intellectual Property.
4 Copyright (c) 2020 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
23 void * rmrInit(void) {
24 void* mrc; // msg router context
26 if( (mrc = rmr_init("tcp:4588", 1024, RMRFL_NONE)) == NULL ) {
27 fprintf(stderr, "Unable to initialize RMR\n");
31 // Must have a route table before we can send, so wait til RMR is ready
32 while(!rmr_ready(mrc)) {
33 fprintf(stderr, "Waiting for RMR to be ready ...\n");
36 fprintf(stderr, "RMR is ready now ...\n");
41 int rmrSend(void *mrc, int mtype, void *payload, int payload_len, char *meid) {
43 rmr_mbuf_t *sbuf = rmr_alloc_msg(mrc, 1024);
46 sbuf->sub_id = RMR_VOID_SUBID;
48 sbuf->len = payload_len;
49 memcpy(sbuf->payload, payload, payload_len);
50 rmr_str2meid(sbuf, meid);
53 sbuf = rmr_send_msg(mrc, sbuf);
58 if (sbuf->state == RMR_OK) {
59 fprintf(stderr, "RMR message sent successfully!\n");
62 } while(sbuf->state == RMR_ERR_RETRY && ++retry_count < 10);
67 rmr_mbuf_t * rmrRcv(void *mrc) {
69 rmr_mbuf_t *rbuf = rmr_rcv_msg(mrc, NULL);
70 if (rbuf != NULL && rbuf->state == RMR_OK) {