| | |
| | | #include "net_mod_server_socket_wrapper.h" |
| | | #include "net_mod_socket_wrapper.h" |
| | | #include "bus_server_socket_wrapper.h" |
| | | |
| | | #include "shm_mm_wraper.h" |
| | | #include "usg_common.h" |
| | | #include <getopt.h> |
| | |
| | | } |
| | | |
| | | |
| | | void start_bus_server(int key) { |
| | | void start_bus_server() { |
| | | printf("Start bus server\n"); |
| | | void * server_socket = net_mod_socket_open(); |
| | | |
| | | net_mod_socket_bind(server_socket, key); |
| | | |
| | | net_mod_socket_start_bus(server_socket); |
| | | void * server_socket = bus_server_socket_wrapper_open(); |
| | | if(bus_server_socket_wrapper_start_bus(server_socket) != 0) { |
| | | printf("start bus failed\n"); |
| | | exit(1); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | else if(strcmp(action, "desub") == 0) { |
| | | printf("Please input buskey and topic!\n"); |
| | | printf("Please input topic!\n"); |
| | | |
| | | scanf("%d %s", &buskey, topic); |
| | | if (net_mod_socket_desub(client, topic, strlen(topic), buskey) == 0) { |
| | | scanf("%s", topic); |
| | | if (net_mod_socket_desub(client, topic, strlen(topic)) == 0) { |
| | | printf("%d Desub success!\n", net_mod_socket_get_key(client)); |
| | | } else { |
| | | printf("Desub failture!\n"); |
| | |
| | | |
| | | } |
| | | else if(strcmp(action, "sub") == 0) { |
| | | printf("Please input buskey and topic!\n"); |
| | | scanf("%d %s",&buskey, topic); |
| | | printf("Please input topic!\n"); |
| | | scanf("%s",topic); |
| | | |
| | | printf("===%d %s\n",buskey, topic); |
| | | if (net_mod_socket_sub(client, topic, strlen(topic), buskey) == 0) { |
| | | if (net_mod_socket_sub(client, topic, strlen(topic)) == 0) { |
| | | printf("%d Sub success!\n", net_mod_socket_get_key(client)); |
| | | } else { |
| | | printf("Sub failture!\n"); |
| | |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | start_bus_server(opt.key); |
| | | start_bus_server(); |
| | | } |
| | | else if (strcmp("start_reply", opt.fun) == 0) { |
| | | if(opt.key == 0) { |
| | |
| | | for(i = 0; i < entry_arr_len; i++) { |
| | | property_arr_len = str_split(entry_arr[i], ":", &property_arr); |
| | | // printf("%s, %s, %s\n", property_arr[0], property_arr[1], property_arr[2]); |
| | | node_arr[i] = {trim(property_arr[0], 0), atoi(property_arr[1]), atoi(property_arr[2])}; |
| | | free(entry_arr[i]); |
| | | node_arr[i] = {trim(property_arr[0], 0), atoi(property_arr[1]), 0}; |
| | | |
| | | free(property_arr[1]); |
| | | free(property_arr[2]); |
| | | if(property_arr_len == 3) { |
| | | node_arr[i].key = atoi(property_arr[2]); |
| | | free(property_arr[2]); |
| | | } |
| | | free(entry_arr[i]); |
| | | |
| | | } |
| | | *node_arr_addr = node_arr; |
| | | |