예제 #1
0
 set_on_error operator= (std::error_code &ec) const {return set_on_error(ec);}
예제 #2
0
파일: main.c 프로젝트: shoutrain/gMaxLinked
int main(int argc, const char *argv[]) {
    if (3 > argc || 7 < argc) {
        printf("Usage: %s <session id> <group id> [ip(%s)] [port(%u)] [interval seconds(%u)] [build number(%u)]\n",
                argv[0], _ip, _port, _intervalSeconds, _buildNum);

        return 1;
    }

    if (16 != strlen(argv[1])) {
        printf("session id is a string with length of 16\n");

        return 2;
    }

    memset(_sessionId, 0, 17);
    strncpy(_sessionId, argv[1], 16);
    _groupId = (unsigned long long) atoll(argv[2]);

    if (0 == _groupId) {
        printf("group id must be integer\n");

        return 2;
    }

    if (3 < argc) {
        if (0 == argv[3][0] || 15 < strlen(argv[3])) {
            printf("%s is invalid ip\n", argv[3]);

            return 4;
        }

        memset(_ip, 0, 16);
        strncpy(_ip, argv[3], 15);
    }

    if (4 < argc) {
        _port = (unsigned short) atoi(argv[4]);

        if (1024 >= _port) {
            printf("%s is invalid port\n", argv[4]);
        }
    }

    if (5 < argc) {
        _intervalSeconds = (unsigned int) atoi(argv[5]);

        if (0 == _intervalSeconds) {
            printf("%s is invalid interval seconds\n", argv[5]);
        }
    }

    if (6 < argc) {
        _buildNum = (unsigned int) atoi(argv[6]);

        if (0 == _buildNum) {
            printf("%s is invalid build num\n", argv[6]);
        }
    }

    set_on_connected(on_connected);
    set_on_ready(on_ready);
    set_on_push(on_push);
    set_on_send_ack(on_send_ack);
    set_on_error(on_error);
    set_on_closed(on_closed);
    net_worker_start(_ip, _port, _intervalSeconds, _buildNum, _sessionId);

    return 0;
}
예제 #3
0
 set_on_error get_initializer() {return set_on_error(*err);};