Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
kostaskougios committed Dec 6, 2023
1 parent d84d951 commit dca0bdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ class HelidonWsTransport(fiberExecutor: FiberExecutor):
def clientWsListener: WsListener = wsListener

def transportFunction(in: TransportInput): Array[Byte] =
if in.argsData.nonEmpty then
throw new IllegalArgumentException("argsData has serialized data, did you use the correct helidon factory methods for the caller?")

val coordsData = in.coordinates4.toRawCoordinatesBytes
val corId = correlationId.incrementAndGet()

val buf = BufferData.growing(in.argsData.length + coordsData.length + 32)
val buf = BufferData.growing(in.data.length + in.argsData.length + coordsData.length + 32)
buf.write(longToBytes(corId))
buf.writeUnsignedInt32(coordsData.length)
buf.write(coordsData)
buf.writeInt32(in.data.length)
buf.write(in.data)
buf.writeInt32(in.argsData.length)
buf.write(in.argsData)
wsListener.send(corId, buf)

def close(): Unit = wsListener.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ class ServerWsListener(invokerMap: Map[Coordinates4, ReceiverInput => Array[Byte
buffer.read(coordsByteData)
val coordsStr = new String(coordsByteData, "UTF-8")
val coordinates4 = Coordinates4.unapply(coordsStr)
val data = buffer.readBytes()
val dataLen = buffer.readInt32()
val data = new Array[Byte](dataLen)
buffer.read(data)
val argLen = buffer.readInt32()
val arg = new Array[Byte](argLen)
buffer.read(arg)
try
val f = im(coordinates4.toRawCoordinates)
val response = f(ReceiverInput(data))
val response = f(ReceiverInput(data, arg))
val buf = BufferData.growing(response.length + 8)
buf.write(0)
buf.write(longToBytes(corId))
Expand Down

0 comments on commit dca0bdb

Please sign in to comment.