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

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

There is a newer version: 5.0.0-dev6
Show 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