Koushik Dutta 在 Android 异步库中设置心跳间隔

Setting heartbeat interval in Android Async library by Koushik Dutta

我正在使用 com.koushikdutta.async:androidasync:2.1.3 作为 Android SocketIO 客户端库。有没有办法更改库中的默认心跳间隔?

心跳已定义here

connecting = httpClient.executeString(request, null)
.then(new TransformFuture<SocketIOTransport, String>() {
    @Override
    protected void transform(String result) throws Exception {
        String[] parts = result.split(":");
        final String sessionId = parts[0];
        if (!"".equals(parts[1]))
            heartbeat = Integer.parseInt(parts[1]) / 2 * 1000;
        else
            heartbeat = 0;

它的后备值确实为 0,但它的 真实 值来自

Integer.parseInt(parts[1]) / 2 * 1000;

According to koush himself:

The heartbeat used by AndroidAsync is derived from the value sent from the server:

heartbeat = Integer.parseInt(parts[1]) / 2 * 1000;

您不能手动更改心跳值。