diff --git a/unittests/rbusMessageTest.cpp b/unittests/rbusMessageTest.cpp index be72f5fd..dd5474c4 100644 --- a/unittests/rbusMessageTest.cpp +++ b/unittests/rbusMessageTest.cpp @@ -150,6 +150,7 @@ static int rbus_send_neg(const char *topic, pid_t pid, int *rbus_recv_status, rb static int rbus_recv(const char *topic, pid_t pid, int *rbus_send_status, rbusGtestMsg_t test) { rbusHandle_t handle; + uint32_t listenerId; int ret = RBUS_ERROR_BUS_ERROR, wait_ret = -1; char *componentName = NULL; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; @@ -521,6 +522,7 @@ static void exec_msg_test(rbusGtestMsg_t test) case RBUS_GTEST_MSG9: { rbusHandle_t rbus; + uint32_t listenerId; EXPECT_EQ(rbus_open(&rbus, "rbus_recv"),0); EXPECT_EQ(rbusMessage_AddListener(rbus, "A.B.C", &rbusRecvHandler, NULL, 0),0); diff --git a/utils/rbuscli/rbuscli.c b/utils/rbuscli/rbuscli.c index 079177bf..f8fef1f6 100644 --- a/utils/rbuscli/rbuscli.c +++ b/utils/rbuscli/rbuscli.c @@ -386,37 +386,6 @@ void show_menu(const char* command) printf ("\tpub Example.MyEvent! \"Hello World\"\n\r"); printf ("\n\r"); } - else if(matchCmd(command, 3, "addlistener")) - { - printf ("\e[1maddl\e[0mistener \e[4mexpression\e[0m\n\r"); - printf ("Add a message listener.\n\r"); - printf ("Args:\n\r"); - printf ("\t%-20sA topic name or topic expression\n\r", "expression"); - printf ("Examples:\n\r"); - printf ("\taddl A.B.C\n\r"); - printf ("\n\r"); - } - else if(matchCmd(command, 3, "remlistener")) - { - printf ("\e[1mreml\e[0mistener \e[4mexpression\e[0m\n\r"); - printf ("Remove a message listener.\n\r"); - printf ("Args:\n\r"); - printf ("\t%-20sA topic name or topic expression\n\r", "expression"); - printf ("Examples:\n\r"); - printf ("\treml A.B.C\n\r"); - printf ("\n\r"); - } - else if(matchCmd(command, 3, "send")) - { - printf ("\e[1msend\e[0m \e[4mtopic\e[0m [\e[4mdata\e[0m]\n\r"); - printf ("Send a message to a topic.\n\r"); - printf ("Args:\n\r"); - printf ("\t%-20sThe topic to send the message to\n\r", "message"); - printf ("\t%-20sThe message data to send (as a string)\n\r", "data"); - printf ("Examples:\n\r"); - printf ("\tsend A.B.C \"Hello World\"\n\r"); - printf ("\n\r"); - } else if(matchCmd(command, 9, "method_noargs")) { printf ("\e[1mmethod_no\e[0margs \e[4mmethodname\e[0m\n\r"); @@ -570,9 +539,6 @@ void show_menu(const char* command) printf ("\t\e[1masub\e[0mscribe \e[4mevent\e[0m [\e[4moperator\e[0m \e[4mvalue\e[0m]\n\r"); printf ("\t\e[1mpub\e[0mlish \e[4mevent\e[0m [\e[4mdata\e[0m]\n\r"); printf ("\t\e[1mrawdatapub\e[0mlish \e[4mevent\e[0m [\e[4mdata\e[0m]\n\r"); - printf ("\t\e[1maddl\e[0mistener \e[4mexpression\e[0m\n\r"); - printf ("\t\e[1mreml\e[0mistener \e[4mexpression\e[0m\n\r"); - printf ("\t\e[1msend\e[0m \e[4mtopic\e[0m [\e[4mdata\e[0m]\n\r"); printf ("\t\e[1mcreate_ses\e[0msion\n\r"); printf ("\t\e[1mget_ses\e[0msion\n\r"); printf ("\t\e[1mclose_ses\e[0msion\n\r"); @@ -2185,99 +2151,6 @@ void validate_and_execute_publish_command(int argc, char *argv[], bool rawDataPu } } -void validate_and_execute_listen_command(int argc, char *argv[], bool add) -{ - rbusError_t rc; - char* userData = NULL; - - if (argc < 2) - { - printf ("Invalid arguments. Please see the help\n\r"); - return; - } - - if (!verify_rbus_open()) - return; - - runSteps = __LINE__; - if(!g_messageUserData) - rtList_Create(&g_messageUserData); - - userData = rt_calloc(1, 256); - sprintf(userData, "listen %s", argv[2]); - - printf("value of argv[2] = %s\n", argv[2]); - printf("value of userData = %s\n", userData); - if(add) - { - rc = rbusMessage_AddListener(g_busHandle, argv[2], message_receive_handler, userData, 0); - } - else - { - rc = rbusMessage_RemoveListener(g_busHandle, argv[2], 0); - } - - if(rc != RBUS_ERROR_SUCCESS) - { - printf("%sListener failed err: %d\n\r", add ? "Add" : "Remove", rc); - rt_free(userData); - } - else - { - if(add) - { - rtList_PushBack(g_messageUserData, userData, NULL); - } - else - { - /* Remove the userData from the list that are maintained for */ - rtListItem li; - rtList_GetFront(g_messageUserData, &li); - runSteps = __LINE__; - while(li) - { - char* prtUserData = NULL; - rtListItem_GetData(li, (void**)&prtUserData); - if(strcmp(prtUserData, userData) == 0) - { - rtList_RemoveItem(g_messageUserData, li, free_userdata); - break; - } - rtListItem_GetNext(li, &li); - } - - rt_free(userData); - } - } -} - -void validate_and_execute_send_command(int argc, char *argv[]) -{ - rbusError_t rc; - rbusMessage_t msg; - - if (argc < 3) - { - printf ("Invalid arguments. Please see the help\n\r"); - return; - } - - if (!verify_rbus_open()) - return; - - msg.topic = argv[2]; - msg.data = (uint8_t const*)argv[3]; - msg.length = strlen(argv[3]); - - runSteps = __LINE__; - rc = rbusMessage_Send(g_busHandle, &msg, RBUS_MESSAGE_CONFIRM_RECEIPT); - - if(rc != RBUS_ERROR_SUCCESS) - { - printf("Send failed err: %d\n\r", rc); - } -} - static void execute_method_cmd(char *cmd, char *method, rbusObject_t inParams) { rbusError_t rc = RBUS_ERROR_SUCCESS; @@ -2564,18 +2437,6 @@ int handle_cmds (int argc, char *argv[]) { validate_and_execute_publish_command (argc, argv, true); } - else if(matchCmd(command, 4, "addlistener")) - { - validate_and_execute_listen_command (argc, argv, true); - } - else if(matchCmd(command, 4, "remlistener")) - { - validate_and_execute_listen_command (argc, argv, false); - } - else if(matchCmd(command, 4, "send")) - { - validate_and_execute_send_command (argc, argv); - } else if(matchCmd(command, 9, "method_values")) { validate_and_execute_method_values_cmd (argc, argv); @@ -2777,8 +2638,7 @@ void completion(const char *buf, linenoiseCompletions *lc) { { runSteps = __LINE__; completion = find_completion(tokens[0], 14, "get", "set", "add", "del", "getr", "getn", "disca", "discc", "disce", - "discw", "sub", "subint", "rawdatasub", "rawdataunsub", "unsub", "unsubint", "asub", "method_no", "method_na", "method_va", "reg", "unreg", "pub", "rawdatapub", - "addl", "reml", "send", "log", "quit", "opend", "closed", "help"); + "discw", "sub", "subint", "rawdatasub", "rawdataunsub", "unsub", "unsubint", "asub", "method_no", "method_na", "method_va", "reg", "unreg", "pub", "rawdatapub", "log", "quit", "opend", "closed", "help"); } else if(num == 2) { @@ -2932,18 +2792,6 @@ char *hints(const char *buf, int *color, int *bold) { { hint = " event [data]"; } - else if(strcmp(tokens[0], "addl") == 0) - { - hint = " expression"; - } - else if(strcmp(tokens[0], "reml") == 0) - { - hint = " expression"; - } - else if(strcmp(tokens[0], "send") == 0) - { - hint = " topic [data]"; - } else if(strcmp(tokens[0], "method_va") == 0) { hint = " methodname parameter type value";