-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parent event id for echo #3
Open
Topru333
wants to merge
19
commits into
master
Choose a base branch
from
eventid_echo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4d3ab44
Parent event id for echo
Topru333 8a1a959
Version updated
Topru333 daba264
loop fix test
Topru333 744c5db
loop fix test
Topru333 06f40f5
Merge branch 'master' into eventid_echo
Topru333 ce1ed4f
parent event id in send method
Topru333 2b59f4c
Event for sent message
Topru333 359d701
Event for sent message (with message data)
Topru333 b64d42c
Minor version up
Topru333 870c9b7
Refactoring
Topru333 3d47d72
Only sent message are reported with event
Topru333 c1c71a6
Readme update
Topru333 6b4c32f
common version updated
Topru333 51d720d
Merge remote-tracking branch 'origin/master' into eventid_echo
Topru333 0b6a7c3
Readme fix
Topru333 ca07c7b
Merge remote-tracking branch 'origin/master' into eventid_echo
Topru333 c59141f
Removed useless events
Topru333 07fc070
Fixed readme and changed current version to 2.3.0
Topru333 95b2a41
Switched merge to rewriting parent event id
Topru333 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
kotlin.code.style=official | ||
kotlin_version=1.4.10 | ||
release_version=0.2.2 | ||
release_version=0.2.3 | ||
description='Websocket Client' | ||
vcs_url=https://github.com/th2-net/th2-conn-ws-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,6 +19,7 @@ package com.exactpro.th2.ws.client.api.impl | |||||
import com.exactpro.th2.common.grpc.Direction | ||||||
import com.exactpro.th2.common.grpc.Direction.FIRST | ||||||
import com.exactpro.th2.common.grpc.Direction.SECOND | ||||||
import com.exactpro.th2.common.grpc.EventID | ||||||
import com.exactpro.th2.ws.client.api.IClient | ||||||
import com.exactpro.th2.ws.client.api.IClientSettings | ||||||
import com.exactpro.th2.ws.client.api.IHandler | ||||||
|
@@ -35,7 +36,7 @@ import kotlin.concurrent.withLock | |||||
class WebSocketClient( | ||||||
private val uri: URI, | ||||||
private val handler: IHandler, | ||||||
private val onMessage: (message: ByteArray, textual: Boolean, direction: Direction) -> Unit, | ||||||
private val onMessage: (message: ByteArray, textual: Boolean, direction: Direction, eventId: EventID?) -> Unit, | ||||||
private val onEvent: (cause: Throwable?, message: () -> String) -> Unit | ||||||
) : IClient, WebSocket.Listener { | ||||||
private val logger = KotlinLogging.logger {} | ||||||
|
@@ -60,18 +61,18 @@ class WebSocketClient( | |||||
return socket | ||||||
} | ||||||
|
||||||
override fun sendText(text: String) { | ||||||
override fun sendText(text: String, eventId: EventID?) { | ||||||
logger.debug { "Sending text: $text" } | ||||||
val preparedText = handler.prepareText(this, text) | ||||||
awaitSocket().sendText(preparedText, true) | ||||||
onMessage(preparedText.toByteArray(), true, SECOND) | ||||||
onMessage(preparedText.toByteArray(), true, SECOND, eventId) | ||||||
} | ||||||
|
||||||
override fun sendBinary(data: ByteArray) { | ||||||
override fun sendBinary(data: ByteArray, eventId: EventID?) { | ||||||
logger.debug { "Sending binary: ${data.toBase64()}" } | ||||||
val preparedData = handler.prepareBinary(this, data) | ||||||
awaitSocket().sendBinary(ByteBuffer.wrap(preparedData), true) | ||||||
onMessage(preparedData, false, SECOND) | ||||||
onMessage(preparedData, false, SECOND, eventId) | ||||||
} | ||||||
|
||||||
override fun sendPing(message: ByteArray) { | ||||||
|
@@ -100,7 +101,7 @@ class WebSocketClient( | |||||
if (last) { | ||||||
val message = if (textFrames.isEmpty()) frame else textFrames.joinToString("") | ||||||
handler.onText(this, message) | ||||||
onMessage(message.toByteArray(), true, FIRST) | ||||||
onMessage(message.toByteArray(), true, FIRST, null) | ||||||
textFrames.clear() | ||||||
} | ||||||
|
||||||
|
@@ -121,7 +122,7 @@ class WebSocketClient( | |||||
if (last) { | ||||||
val message = if (binaryFrames.isEmpty()) frame else binaryFrames.reduce(ByteArray::plus) | ||||||
handler.onBinary(this, message) | ||||||
onMessage(message, false, FIRST) | ||||||
onMessage(message, true, FIRST, null) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
binaryFrames.clear() | ||||||
} | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll always be non-null. We should check its presence through
hasParentEventId
method instead and passnull
if it returnsfalse