I’m developing an application using websocket api and in order to implement it properly, I’m using Scarlet library because it’s so similar to Retrofit but I keep getting this error. I use the 0.2.5-SNAPSHOT version of this library and trying to use coroutines.
Here is my code for Scarlet configuration:
val loggingInterceptor = HttpLoggingInterceptor()
val interceptor = loggingInterceptor.apply {
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
}
val httpClient: OkHttpClient = OkHttpClient.Builder()
.readTimeout(2000 , TimeUnit.MILLISECONDS)
.writeTimeout(2000, TimeUnit.MILLISECONDS)
.followRedirects(false)
.connectTimeout(3000 , TimeUnit.MILLISECONDS)
.addInterceptor(interceptor)
.build()
val scarlet = Scarlet(
OkHttpWebSocket (
httpClient,
OkHttpWebSocket.SimpleRequestFactory(
{ Request.Builder().url(baseUrl).build()},
{ ShutdownReason.GRACEFUL }
)
),
Scarlet.Configuration (
backoffStrategy = LinearBackoffStrategy(3000),
messageAdapterFactories = listOf(MoshiMessageAdapter.Factory()),
streamAdapterFactories = listOf(CoroutinesStreamAdapterFactory()),
)
)
val bitService = scarlet.create(BitService::class.java)
bitService.authenticateUser(
RequestDataFrame(
messageType = 0,
sequenceNumber = 0,
functionName = "AuthenticateUser",
payloadRequest = "{UserName:, Password:}"
)
)
I added the required maven repository for getting the snapshot version.
Also if you know any better solution for websocket implementation which is similar to Retrofit in a clean way , please let me know !
You need to sign in to view this answers
Leave feedback about this