Skip to content
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

Fix compiler error upgrading lightstreamer version #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compile ("org.jetbrains.kotlinx:kotlinx-coroutines-core")

compile("com.lightstreamer:ls-javase-client:3.1.1")
compile("com.lightstreamer:ls-javase-client:4.3.7")

compile("com.fasterxml.jackson.module:jackson-module-kotlin:2.10.2")

Expand Down
Binary file modified drivers/windows/chromedriver.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>com.lightstreamer</groupId>
<artifactId>ls-javase-client</artifactId>
<version>3.1.1</version>
<version>4.3.7</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/ok/work/etoroapi/client/EtoroHttpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import javax.annotation.PostConstruct
import kotlin.math.log


data class ViewContext(val ClientViewRate: Double)
Expand Down Expand Up @@ -116,7 +117,12 @@ class EtoroHttpClient {
if (!imageData.has("Uri")) {
continue;
}
val image = Image(imageData.getInt("Width"), imageData.getInt("Height"), imageData.getString("Uri"))
val image = Image(0,0, "");
try {
val image = Image(imageData.getInt("Width"), imageData.getInt("Height"), imageData.getString("Uri"))
Copy link

@pedroestima-sgg pedroestima-sgg Jun 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are overriding image, remove val on this line and change val image to var on line 120

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still doesn't fix the issue around the non-updating watchlist...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add a required boolean parameter to CreateSessionRequest class constructor, otherwise the request silently crashes. However, at least for me, the updates still don't occur even after

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class CreateSessionRequest(targetServer: String, polling: Boolean, cause: String?, options: InternalConnectionOptions, details: InternalConnectionDetails, delay: Long, password: String?, oldSession: String?, serverBusy: Boolean) : SessionRequest(polling, delay) {

} catch (e: Exception) {

}
imageList.add(image)
}
var id: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ class EtoroMetadataService(@Value("\${etoro.baseUrl}") val baseUrl: String, @Val

opts = ChromeOptions()
System.setProperty("webdriver.chrome.driver", pathToDriver)
opts.addArguments("start-maximized")
opts.addArguments("--no-sandbox"); // Bypass OS security model
opts.addArguments("start-maximized"); // open Browser in maximized mode
opts.addArguments("disable-infobars"); // disabling infobars
opts.addArguments("--disable-extensions"); // disabling extensions
opts.addArguments("--disable-gpu"); // applicable to windows os only
opts.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
opts.addArguments("--disable-blink-features=AutomationControlled")
login()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import com.lightstreamer.client.SubscriptionListener

open class EtoroListener : SubscriptionListener {

override fun onRealMaxFrequency(p0: String?) {
println("onRealMaxFrequency")
}

override fun onListenEnd(subscription: Subscription) {
println("onListenEnd")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EtoroPriceListener : EtoroListener() {
}

override fun onItemUpdate(itemUpdate: ItemUpdate) {
val id = itemUpdate.itemName.replace("instrument:", "")
val id = itemUpdate.itemName!!.replace("instrument:", "")

if (watchlist.getById(id) !== null) {
watchlist.updatePrice(id, itemUpdate.getValue(2), itemUpdate.getValue(3))
Expand All @@ -36,7 +36,7 @@ class EtoroPriceListener : EtoroListener() {
val log = StringBuilder()
var update = HashMap<String, String>()
for (i in 1..subscriptionFields.size) {
update.put(subscriptionFields[i-1], itemUpdate.getValue(i))
update.put(subscriptionFields[i-1], itemUpdate.getValue(i).toString())
log.append("${itemUpdate.getValue(i)} | ")
}
println(log.toString())
Expand Down