Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
lh70 committed Aug 22, 2024
1 parent 89fccb5 commit 559b7f8
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Modules/DTN/shared/src/main/scala/dtn/WSConnection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class WSConnection(ws: WebSocket[Future]) {
}
}

def sendBinary(payload: Array[Byte]): Future[Unit] = ws.sendBinary(payload)
def sendBinary(payload: Array[Byte]): Future[Unit] = ws.sendBinary(payload).recover(_.printStackTrace())

def sendText(payload: String): Future[Unit] = ws.sendText(payload)
def sendText(payload: String): Future[Unit] = ws.sendText(payload).recover(_.printStackTrace())

def close(): Future[Unit] = ws.close()
}
Expand All @@ -81,8 +81,6 @@ object WSConnection {
class WSEndpointClient(host: String, port: Int, connection: WSConnection, val nodeId: String) {
protected var registeredServices: List[String] = List()

private val lock: AtomicBoolean = new AtomicBoolean(false)

def receiveBundle(): Future[Bundle] = {
/*
We have a problem:
Expand All @@ -99,8 +97,6 @@ class WSEndpointClient(host: String, port: Int, connection: WSConnection, val no
// we throw an Exception if this is not the case
println(s"received command response: $s")

if s.startsWith("200 Sent payload") then lock.set(false)

if !s.startsWith("200") then
println(
s"dtn ws command response indicated 'not successfull', further interaction with the ws will likely fail: $s"
Expand All @@ -115,7 +111,6 @@ class WSEndpointClient(host: String, port: Int, connection: WSConnection, val no

def sendBundle(bundle: Bundle): Future[Unit] = {
println(s"starting to send bundle at time: ${ZonedDateTime.now()}")
while !lock.compareAndSet(false, true) do {}
connection.sendBinary(Cbor.encode(bundle).toByteArray).map(u => {
println(s"sent bundle at time: ${ZonedDateTime.now()}")
u
Expand Down

0 comments on commit 559b7f8

Please sign in to comment.