Ejemplo n.º 1
0
int HLR2::activate(const char *msisdn)
{
    LOG_INFO("%s::%s: msisdn: %s", __class__, __func__, msisdn);

    if (0 > _login(msisdn)) { 
        LOG_ERROR("%s::%s: Unable to login!", __class__, __func__);
        return -1;
    }

    //-- get imsi...
    if (0 > _getIMSI()) {
        LOG_ERROR("%s::%s: Unable to get IMSI information!", __class__, __func__);
        _logout();
        return -1;
    }

    for (int i = 0; i < (int)_activate_steps.size(); ++i) {
        if (0 > (this->*_activate_steps[i].execute)()) {
            for (int j = i; j >= 0; --j) {
                if (0 > (this->*_activate_steps[j].rollback)()) {
                    LOG_ERROR("%s::%s: Failed: %s", __class__, __func__, this->_activate_steps[j].rollback_desc);
                }
            }
            LOG_ERROR("%s::%s: Failed: %s", __class__, __func__, this->_activate_steps[i].execute_desc);
            _logout();
            return -1;
        }
    }

    //-- successful
    _logout();

    return 0;
}
Ejemplo n.º 2
0
void
game_usermsg(struct service* s, int id, void* msg, int sz) {
    struct game* self = SERVICE_SELF;
    struct gate_message* gm = msg;
    assert(gm->c);
    UM_CAST(UM_BASE, um, gm->msg);
    switch (um->msgid) {
    case IDUM_GAMELOGIN:
        _login(self, gm->c, um);
        break;
    case IDUM_GAMELOGOUT:
        _logout(self, gm->c, true, true);
        break;
    case IDUM_GAMELOADOK:
        _loadok(self, gm->c);
        break;
    case IDUM_GAMESYNC:
        _sync(self, gm->c, um);
        break;
    case IDUM_ROLEPRESS:
        _role_press(self, gm->c, um);
        break;
    case IDUM_USEITEM:
        _use_item(self, gm->c, um);
        break;
    }
}
Ejemplo n.º 3
0
void
game_net(struct service* s, struct gate_message* gm) {
    struct game* self = SERVICE_SELF;
    struct net_message* nm = gm->msg;
    switch (nm->type) {
    case NETE_SOCKERR:
    case NETE_TIMEOUT:
        _logout(self, gm->c, false, true);
        break;
    }
}
Ejemplo n.º 4
0
int HLR2::getIMSI(const char *msisdn, char *imsi, int imsi_size)
{
    LOG_INFO("%s::%s: msisdn: %s", __class__, __func__, msisdn);

    if (0 > _login(msisdn)) {
        return -1;
    }

    int status = _getIMSI();
    snprintf(imsi, imsi_size, "%s", _imsi.c_str());
    LOG_DEBUG("%s::%s: msisdn: %s, imsi: %s", __class__, __func__, msisdn, imsi);

    _logout();

    return status;
}
Ejemplo n.º 5
0
static void
_destory_room(struct game* self, struct room* ro) {
    struct member* m;
    int i;
    for (i=0; i<ro->np; ++i) {
        m = &ro->p[i];
        if (m->online) {
            _freemember(m);
            struct gate_client* c = sc_gate_getclient(m->connid);
            if (c) {
                _logout(self, c, true, false);
            }
        }
    }
    if (ro->map) {
        genmap_free(ro->map);
        ro->map = NULL;
    }
    GFREEID_FREE(room, &self->rooms, ro);
}