All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.firefly.kotlin.ext.websocket.WebSocketClientExtension.kt Maven / Gradle / Ivy

The newest version!
package com.firefly.kotlin.ext.websocket

import com.firefly.client.websocket.SimpleWebSocketClient
import com.firefly.codec.websocket.stream.WebSocketConnection
import kotlinx.coroutines.future.await
import kotlinx.coroutines.withTimeout
import java.util.concurrent.TimeUnit

/**
 * @author Pengtao Qiu
 */
suspend fun SimpleWebSocketClient.HandshakeBuilder.asyncConnect(
    time: Long = 10 * 1000L,
    unit: TimeUnit = TimeUnit.MILLISECONDS
                                                               ): WebSocketConnection =
    withTimeout(unit.toMillis(time)) { connect().await() }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy