Skip to content

Commit

Permalink
Add heart beat field to ClientOpenRequest and remove ClientCloseRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
ZaltsmanNikita committed Jan 10, 2020
1 parent 3450913 commit bbe55f4
Showing 1 changed file with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.tinder.scarlet.stomp.okhttp
import com.tinder.scarlet.Channel
import com.tinder.scarlet.Protocol
import com.tinder.scarlet.ProtocolSpecificEventAdapter
import com.tinder.scarlet.stomp.core.StompHeader
import com.tinder.scarlet.utils.SimpleProtocolCloseRequestFactory
import com.tinder.scarlet.utils.SimpleProtocolOpenRequestFactory
import okhttp3.OkHttpClient
import okhttp3.Request
Expand All @@ -31,45 +29,30 @@ class OkHttpStompClient(
}
}

override fun createCloseRequestFactory(channel: Channel): Protocol.CloseRequest.Factory {
return SimpleProtocolCloseRequestFactory {
requestFactory.createClientCloseRequest()
}
}

override fun createEventAdapterFactory(): ProtocolSpecificEventAdapter.Factory {
return object : ProtocolSpecificEventAdapter.Factory {}
}

interface RequestFactory {
fun createClientCloseRequest(): ClientCloseRequest
fun createClientOpenRequest(): ClientOpenRequest
}

open class SimpleRequestFactory(
private val createClientCloseRequestCallable: () -> ClientCloseRequest,
private val createClientOpenRequestCallable: () -> ClientOpenRequest
) : RequestFactory {

override fun createClientCloseRequest(): ClientCloseRequest {
return createClientCloseRequestCallable()
}

override fun createClientOpenRequest(): ClientOpenRequest {
return createClientOpenRequestCallable()
}
}

data class ClientOpenRequest(
val host: String,
val okHttpRequest: Request,
val heartbeatSendInterval: Long = 0,
val heartbeatReceiveInterval: Long = 0,
val login: String? = null,
val passcode: String? = null,
val okHttpRequest: Request
val passcode: String? = null
) : Protocol.OpenRequest

data class ClientCloseRequest(
val code: Int,
val reason: String
) : Protocol.CloseRequest

}

0 comments on commit bbe55f4

Please sign in to comment.