diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-22 22:42:22 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-22 22:42:22 +0200 |
commit | db5612ed9734d51e6fcd0d7b5a7635e49b773581 (patch) | |
tree | e23e607c9d9eeedc377bf44e57c2b58b41d0389d /src/scalevalapokalypsi/Client/ReceivedLineParser.scala | |
parent | 49985d1d11c426968fc298469671326aace96d00 (diff) | |
download | scalevalapokalypsi-db5612ed9734d51e6fcd0d7b5a7635e49b773581.tar.gz scalevalapokalypsi-db5612ed9734d51e6fcd0d7b5a7635e49b773581.zip |
Character safety checking, supported terminals updated
Diffstat (limited to 'src/scalevalapokalypsi/Client/ReceivedLineParser.scala')
-rw-r--r-- | src/scalevalapokalypsi/Client/ReceivedLineParser.scala | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/scalevalapokalypsi/Client/ReceivedLineParser.scala b/src/scalevalapokalypsi/Client/ReceivedLineParser.scala index 9337ce1..bccba59 100644 --- a/src/scalevalapokalypsi/Client/ReceivedLineParser.scala +++ b/src/scalevalapokalypsi/Client/ReceivedLineParser.scala @@ -2,6 +2,7 @@ package scalevalapokalypsi.Client import scala.collection.mutable.Buffer import scalevalapokalypsi.constants.* +import scalevalapokalypsi.utils.* /** A class for checking asynchronously for received lines */ class ReceivedLineParser: @@ -10,11 +11,11 @@ class ReceivedLineParser: private var bufferedData: Buffer[Byte] = Buffer.empty // TODO: suboptimal DS - /** Add received data */ + /** Add received data */ def in(data: Array[Byte]): Unit = this.bufferedData ++= data - /** Read a line from the received data */ + /** Read a line from the received data */ def nextLine(): Option[String] = val indexOfCRLF = this.bufferedData.indexOfSlice(CRLF) if indexOfCRLF == -1 then @@ -22,6 +23,6 @@ class ReceivedLineParser: else val splitData = this.bufferedData.splitAt(indexOfCRLF) this.bufferedData = Buffer.from(splitData(1).drop(CRLF.length)) - Some(String(splitData(0).toArray)) + byteArrayToString(splitData(0).toArray) end ReceivedLineParser |