예제 #1
0
파일: node.c 프로젝트: buidanhquy/group-man
/*
void on_request_adv_server(adv_server_t *adv_server, adv_request_t *request) {
    //TODO
    SHOW_LOG(4, fprintf(stdout,"Received: ID = %s\nSDP addr %s:%d\n", request->adv_info.info_id, request->adv_info.sdp_mip, request->adv_info.sdp_port));
}
*/
void on_request_gmc_server(gmc_server_t *gmc_server, gmc_request_t *request) {
    node_t *node = gmc_server->user_data;
    SHOW_LOG(5, fprintf(stdout, "Receive something\n"));
    switch(request->msg_id) {
        case GMC_GROUP:
            SHOW_LOG(4, fprintf(stdout, "Received request:\nAction: %d - Adv_ip: %s\n", 
                    request->gmc_group.join, request->gmc_group.adv_ip));
            if (request->gmc_group.join == 1) {
                SHOW_LOG(4, fprintf(stdout, "Join %s\n", request->gmc_group.adv_ip));
                adv_server_join(&node->adv_server, request->gmc_group.adv_ip);
            }
            else if (request->gmc_group.join == 0) {
                SHOW_LOG(4, fprintf(stdout, "Leave %s\n", request->gmc_group.adv_ip));
                adv_server_leave(&node->adv_server, request->gmc_group.adv_ip);
            }
            else {
                EXIT_IF_TRUE(1, "Unknow action\n");
            }
            break;
        default:
            EXIT_IF_TRUE(1, "Unknow request\n");
    }
}
예제 #2
0
파일: riuc4.c 프로젝트: mocidis/riuc-v1
void on_leaving_server(char *owner_id, char *adv_ip) {
    int *pret;
    int i, ret;
    int count = 0;
    for (i = 0; i < MAX_NODE; i++) {
        pret = (int *)ht_get_item(&riuc_data.node[i].group_table, (void *)owner_id);

        if (pret != NULL) {
            ret = *pret;
            if (ret < 0) {
                count++;
            }
        }
        if (pret == NULL) {
            count++;
        }
    }

    if (count == MAX_NODE) {
        SHOW_LOG(3, "Leave %s\n", adv_ip);
        adv_server_leave(riuc_data.node[0].adv_server, adv_ip);
    }
}
예제 #3
0
파일: OIUC.cpp 프로젝트: mocidis/oiuc-v1
void on_leaving_server(char *owner_id, char *adv_ip) {
    app_data_t *app_data;
    app_data = OIUC::getOIUC()->getAppData();

    adv_server_leave(app_data->node.adv_server, adv_ip);
}