Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
842f935
Update kotlin and gradle plugin version
ZaltsmanNikita Jan 4, 2020
abec7bc
Increase build tools
ZaltsmanNikita Jan 4, 2020
e4d135a
Add stomp server and client command enum
ZaltsmanNikita Jan 8, 2020
20e63eb
Add first okhttp stomp protocol implementation
ZaltsmanNikita Jan 8, 2020
226d782
Add stomp core classes
ZaltsmanNikita Jan 9, 2020
a90fe5a
Add mock implementation for stomp message encoder and message decoder
ZaltsmanNikita Jan 10, 2020
cee1d9c
Update okhttpstompdestination, change interfaces to typealias
ZaltsmanNikita Jan 10, 2020
e0fc49a
Add send message methods
ZaltsmanNikita Jan 10, 2020
ba1f936
Add message sender to OkHttpStompMessageChannel
ZaltsmanNikita Jan 10, 2020
f082436
add heart beat header
ZaltsmanNikita Jan 10, 2020
9d79bdf
Remove extra request and clear subscriptions
ZaltsmanNikita Jan 10, 2020
ac7e5cf
Add connection abstraction for easy heart beat control
ZaltsmanNikita Jan 10, 2020
f5c19ab
Add heart beat field to ClientOpenRequest and remove ClientCloseRequest
ZaltsmanNikita Jan 10, 2020
ce23067
Remove gazirra stomp client
ZaltsmanNikita Jan 10, 2020
cd25f3f
Add heartbeat support to main channel and add error message custom he…
ZaltsmanNikita Jan 10, 2020
3d84e99
Add shutdown executor after close connection
ZaltsmanNikita Jan 13, 2020
3aa1cac
Fix case with message with empty destination and fix bug with setup h…
ZaltsmanNikita Jan 13, 2020
9cb2975
Rename Message Channel
ZaltsmanNikita Jan 13, 2020
2bc7724
Move settings to configuration class and rename main channel
ZaltsmanNikita Jan 13, 2020
eb29299
Revert "Remove gazirra stomp client"
ZaltsmanNikita Jan 15, 2020
18df82b
Add documentation for StomHeader
ZaltsmanNikita Jan 15, 2020
bf65dd7
add mock implementation of stomp decoder
ZaltsmanNikita Mar 7, 2020
fbc9b19
fix di config
ZaltsmanNikita Mar 7, 2020
b9c10d5
add documentation
ZaltsmanNikita Mar 7, 2020
d027a51
fix test package name
ZaltsmanNikita Mar 7, 2020
ffa9805
add message decoder implementation
ZaltsmanNikita Mar 8, 2020
680f8f5
Add id generator interface
ZaltsmanNikita Mar 8, 2020
9b7dc5a
refactoring stomp header accessor
ZaltsmanNikita Mar 9, 2020
7cef97e
add integration test for ok http stomp
ZaltsmanNikita Mar 14, 2020
52b54c3
Add OkHttpStompWebSocketConnection
ZaltsmanNikita Mar 14, 2020
f6469be
Fix bug on okHttpStompIntegrationTest
ZaltsmanNikita Mar 26, 2020
bc561c9
Add handler for case for unexpected server disconnect
ZaltsmanNikita Aug 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/android:api-28-alpha
- image: circleci/android:api-29
environment:
TERM: dumb
JAVA_TOOL_OPTIONS: "-Xmx1g"
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.3.61'
ext.dokka_version = '0.9.16'
repositories {
mavenCentral()
Expand All @@ -10,7 +10,7 @@ buildscript {
}
dependencies {
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
4 changes: 4 additions & 0 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/ASL-2.0.txt'
Expand Down
9 changes: 6 additions & 3 deletions demo/src/main/java/com/tinder/app/root/view/DemoActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ class DemoActivity : AppCompatActivity() {
tabLayout.addOnTabSelectedListener(TabLayout.ViewPagerOnTabSelectedListener(viewPager))
}

private class ViewPagerAdapter constructor(fm: FragmentManager, private val pageCount: Int) :
FragmentStatePagerAdapter(fm) {
override fun getItem(position: Int): Fragment? {
private class ViewPagerAdapter(
fm: FragmentManager,
private val pageCount: Int
) : FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

override fun getItem(position: Int): Fragment {
val (_, createFragment) = TAB_ITEMS[position]
return createFragment()
}
Expand Down
43 changes: 26 additions & 17 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ext {
minSdkVersion = 24
minSdkVersionAndroidLifecycle = 19
targetSdkVersion = 28
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
targetSdkVersion = 29
compileSdkVersion = 29
buildToolsVersion = '29.0.0'

appCompat = 'androidx.appcompat:appcompat:1.0.0'
appCompat = 'androidx.appcompat:appcompat:1.1.0'
lifecycleExtensions = 'androidx.lifecycle:lifecycle-extensions:2.0.0'
material = 'com.google.android.material:material:1.0.0'
multiDex = 'androidx.multidex:multidex:2.0.0'
Expand All @@ -17,16 +17,22 @@ ext {
rxJava3 = 'io.reactivex.rxjava3:rxkotlin:3.0.0'
rxAndroid3 = 'io.reactivex.rxjava3:rxandroid:3.0.0'
rxKotlin3 = 'io.reactivex.rxjava3:rxkotlin:3.0.0'
rxJava = 'io.reactivex.rxjava2:rxjava:2.1.16'
rxAndroid = 'io.reactivex.rxjava2:rxandroid:2.0.2'
rxKotlin = 'io.reactivex.rxjava2:rxkotlin:2.2.0'

def rxJavaVersion = "2.2.15"
def rxAndroidVersion = "2.1.1"
def rxKotlinVersion = "2.4.0"
rxJava = "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
rxAndroid = "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
rxKotlin = "io.reactivex.rxjava2:rxkotlin:$rxKotlinVersion"
rxJava1 = 'io.reactivex:rxjava:1.3.4'

kotlinCoroutines = 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
kotlinCoroutinesRxInterop = 'org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.3.2'
kotlinCoroutinesTest = 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.2'

stetho = 'com.facebook.stetho:stetho:1.5.0'
stethoOkHttp = 'com.facebook.stetho:stetho-okhttp3:1.5.0'
def stethoVersion = "1.5.0"
stetho = "com.facebook.stetho:stetho:$stethoVersion"
stethoOkHttp = "com.facebook.stetho:stetho-okhttp3:$stethoVersion"

moshi = 'com.squareup.moshi:moshi-kotlin:1.5.0'
moshiCodeGen = 'com.squareup.moshi:moshi-kotlin-codegen:1.6.0'
Expand All @@ -44,20 +50,23 @@ ext {
jodaTime = 'joda-time:joda-time:2.9.9'
glide = 'com.github.bumptech.glide:glide:4.5.0'

okHttp = 'com.squareup.okhttp3:okhttp:3.11.0'
okHttpServerSentEvent = 'com.squareup.okhttp3:okhttp-sse:3.11.0'
okHttpLoggingInterceptor = 'com.squareup.okhttp3:logging-interceptor:3.11.0'
okio = 'com.squareup.okio:okio:1.13.0'
def okHttpVersion = "3.12.7"
okHttp = "com.squareup.okhttp3:okhttp:$okHttpVersion"
okHttpServerSentEvent = "com.squareup.okhttp3:okhttp-sse:$okHttpVersion"
okHttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:$okHttpVersion"

okio = 'com.squareup.okio:okio:2.5.0'
mockWebServer = 'com.squareup.okhttp3:mockwebserver:3.11.0'
timber = 'com.jakewharton.timber:timber:4.6.0'
okSse = 'com.github.heremaps:oksse:0.9.0'
socketIoClient = 'io.socket:socket.io-client:1.0.0'
nettySocketIoServer = 'com.corundumstudio.socketio:netty-socketio:1.7.12'
pahoMqtt = 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0'
activeMqJUnit = 'org.apache.activemq.tooling:activemq-junit:5.13.1'
activeMqBroker = 'org.apache.activemq:activemq-broker:5.15.6'
activeMqStomp = 'org.apache.activemq:activemq-stomp:5.15.6'
activeMqMqtt = 'org.apache.activemq:activemq-mqtt:5.15.6'
activeMqJUnit = 'org.apache.activemq.tooling:activemq-junit:5.15.11'
activeMqBroker = 'org.apache.activemq:activemq-broker:5.15.11'
activeMqStomp = 'org.apache.activemq:activemq-stomp:5.15.11'
activeMqMqtt = 'org.apache.activemq:activemq-mqtt:5.15.11'
activeHttp = 'org.apache.activemq:activemq-http:5.15.11'
slf4jSimple = 'org.slf4j:slf4j-simple:1.7.25'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal class JacksonMessageAdapterTest {
any<WebSocketEvent.OnConnectionOpened>(),
any<WebSocketEvent.OnMessageReceived>().containingText(expectedString)
)
serverAnImplementationObserver.awaitCount(1)
serverAnImplementationObserver.awaitCountAndCheck(1)
assertThat(serverAnImplementationObserver.values).containsExactly(data)
}

Expand All @@ -79,7 +79,7 @@ internal class JacksonMessageAdapterTest {
any<WebSocketEvent.OnConnectionOpened>(),
any<WebSocketEvent.OnMessageReceived>().containingText(expectedString)
)
serverAnImplementationObserver.awaitCount(1)
serverAnImplementationObserver.awaitCountAndCheck(1)
assertThat(serverAnImplementationObserver.values).containsExactly(data)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PahoMqttClientIntegrationTest {
connection1.clientClosure()

LOGGER.info("${queueTextObserver.values}")
queueTextObserver.awaitCount(2)
queueTextObserver.awaitCountAndCheck(2)
}

companion object {
Expand Down
6 changes: 6 additions & 0 deletions scarlet-protocol-stomp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ dependencies {

implementation project(':scarlet-core-internal')
implementation rootProject.ext.rxJava
implementation rootProject.ext.okio
implementation rootProject.ext.kotlinStdlib

api rootProject.ext.okHttp

testImplementation project(':scarlet-test-utils')
testImplementation rootProject.ext.junit
testImplementation rootProject.ext.mockito
Expand All @@ -23,5 +26,8 @@ dependencies {
testImplementation rootProject.ext.activeMqJUnit
testImplementation rootProject.ext.activeMqBroker
testImplementation rootProject.ext.activeMqStomp
testImplementation rootProject.ext.activeHttp
testImplementation rootProject.ext.slf4jSimple

testImplementation "javax.servlet:javax.servlet-api:4.0.1"
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* © 2018 Match Group, LLC.
*/
package com.tinder.scarlet.stomp.okhttp.client

import com.tinder.scarlet.Channel
import com.tinder.scarlet.Protocol
import com.tinder.scarlet.ProtocolSpecificEventAdapter
import com.tinder.scarlet.stomp.okhttp.core.IdGenerator
import com.tinder.scarlet.stomp.okhttp.core.WebSocketFactory
import com.tinder.scarlet.stomp.okhttp.generator.UuidGenerator
import com.tinder.scarlet.utils.SimpleProtocolOpenRequestFactory
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.WebSocketListener

/**
* Scarlet protocol implementation for create StompMainChannel
* @see OkHttpStompMainChannel
*/
class OkHttpStompClient(
private val configuration: OkHttpStompMainChannel.Configuration,
private val okHttpClient: OkHttpClient,
private val requestFactory: (Channel) -> ClientOpenRequest,
private val idGenerator: IdGenerator = UuidGenerator()
) : Protocol {

override fun createChannelFactory() = OkHttpStompMainChannel.Factory(
idGenerator = idGenerator,
configuration = configuration,
webSocketFactory = object : WebSocketFactory {
override fun createWebSocket(request: Request, listener: WebSocketListener) {
okHttpClient.newWebSocket(request, listener)
}
}
)

override fun createOpenRequestFactory(
channel: Channel
) = SimpleProtocolOpenRequestFactory {
requestFactory.invoke(channel)
}

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

data class ClientOpenRequest(
val okHttpRequest: Request,
val login: String? = null,
val passcode: String? = null
) : Protocol.OpenRequest
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* © 2018 Match Group, LLC.
*/
package com.tinder.scarlet.stomp.okhttp.client

import com.tinder.scarlet.Channel
import com.tinder.scarlet.Message
import com.tinder.scarlet.Protocol
import com.tinder.scarlet.ProtocolSpecificEventAdapter
import com.tinder.scarlet.stomp.okhttp.models.StompHeader
import com.tinder.scarlet.utils.SimpleChannelFactory
import com.tinder.scarlet.utils.SimpleProtocolOpenRequestFactory

private typealias DestinationOpenRequestHeaderFactory = (Channel) -> OkHttpStompDestination.DestinationOpenRequest
private typealias MessageMetaDataFactory = (Channel, Message) -> OkHttpStompDestination.MessageMetaData

/**
* Scarlet protocol implementation for create channel (OkHttpStompMessageChannel) for subscribe to
* queue by destination.
* @see OkHttpStompMessageChannel
*
* MessageMetaDataFactory is optional factory for create custom header for each message which will be sent
* by this StompMessageChannel.
*
* DestinationOpenRequestHeaderFactory is optional factory for create open request header which will be sent
* with subscribe message.
*/
class OkHttpStompDestination(
private val destination: String,
private val openRequestFactory: DestinationOpenRequestHeaderFactory? = null,
private val createMessageMetaDataCallable: MessageMetaDataFactory? = null
) : Protocol {

override fun createChannelFactory() = SimpleChannelFactory { listener, parent ->
require(parent is OkHttpStompMainChannel)
OkHttpStompMessageChannel(destination, parent, parent, listener)
}

override fun createOpenRequestFactory(channel: Channel) = SimpleProtocolOpenRequestFactory {
openRequestFactory?.invoke(channel) ?: Protocol.OpenRequest.Empty
}

override fun createOutgoingMessageMetaDataFactory(
channel: Channel
) = SimpleMessageMetaDataFactory(createMessageMetaDataCallable)

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

class SimpleMessageMetaDataFactory(
private val createMessageMetaDataCallable: MessageMetaDataFactory?
) : Protocol.MessageMetaData.Factory {

override fun create(
channel: Channel,
message: Message
) = createMessageMetaDataCallable?.invoke(channel, message)
?: Protocol.MessageMetaData.Empty
}

data class MessageMetaData(
val headers: StompHeader
) : Protocol.MessageMetaData

data class DestinationOpenRequest(
val headers: StompHeader
) : Protocol.OpenRequest
}
Loading