Open tobioyelekan opened 3 years ago
Creating a second Service like this makes the socket reconnect, thereby opening multiple connections
@Provides @Singleton fun provideAuthService(scarlet: Scarlet): Service1 { return scarlet.create(Service1::class.java) } @Provides @Singleton fun providesUserService(scarlet: Scarlet): Service2 { return scarlet.create(Service2::class.java) } @Provides @Singleton fun providesScarlet(): Scarlet { val client = OkHttpClient.Builder() .connectTimeout(60, TimeUnit.SECONDS) .readTimeout(60, TimeUnit.SECONDS) .writeTimeout(60, TimeUnit.SECONDS) return Scarlet.Builder() .webSocketFactory(client.build().newWebSocketFactory(baseUrl)) .addMessageAdapterFactory( WebSocketMessageAdapter.Factory() ) .addStreamAdapterFactory(FlowStreamAdapter.Factory) //.lifecycle(AndroidLifecycle.ofApplicationForeground(application)) .backoffStrategy(BACKOFF_STRATEGY) //remove .build() }
Is this an intended behavior? because having just one service with a long list of @Send and @Receive doesn't look neat.
@Send
@Receive
Сould you find a solution?
Creating a second Service like this makes the socket reconnect, thereby opening multiple connections
Is this an intended behavior? because having just one service with a long list of
@Send
and@Receive
doesn't look neat.