Skip to content

Commit

Permalink
fix: unable detect ibgw status
Browse files Browse the repository at this point in the history
  • Loading branch information
manhinhang committed Apr 20, 2024
1 parent 9aa2940 commit 61985e1
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ class IBGatewayClient {
return client
}

suspend fun connect():Boolean = withContext(Dispatchers.IO) {
private suspend fun connect():Boolean = withContext(Dispatchers.IO) {
if (!client.isConnected) {
val client = createIBClient()
client.eConnect(host, port, clientId)
}
client.isConnected
}

fun disconnect() {
private fun disconnect() {
client.eDisconnect()
}

Expand All @@ -39,7 +38,7 @@ class IBGatewayClient {
val isConnected = connect()
if (isConnected) {
println("Ping IB Gateway successful")
client.eDisconnect()
disconnect()
}else {
throw InterruptedException("Can not connect to IB Gateway")
}
Expand Down

0 comments on commit 61985e1

Please sign in to comment.