diff options
Diffstat (limited to 'src/main/scala/Server/Server.scala')
-rw-r--r-- | src/main/scala/Server/Server.scala | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main/scala/Server/Server.scala b/src/main/scala/Server/Server.scala index c0a76ca..6fa284c 100644 --- a/src/main/scala/Server/Server.scala +++ b/src/main/scala/Server/Server.scala @@ -3,14 +3,17 @@ package o1game.Server // TODO: TLS/SSL / import javax.net.ssl.SSLServerSocketFactory -import java.io.IOException import java.lang.Thread.sleep import java.net.{ServerSocket, Socket} import o1game.constants.* import o1game.Model.Adventure import o1game.Model.Entity -import scala.collection.mutable.Map +/** Converts this string to an array of bytes (probably for transmission). + * + * @param str the string to convert + * @return an array of bytes representing the string in UTF8. + */ def stringToByteArray(str: String): Array[Byte] = str.toVector.map(_.toByte).toArray @@ -50,9 +53,9 @@ class Server(port: Int, maxClients: Int, val timeLimit: Int): /** Receives a new client and stores it in `clients`. - * - * @return describes if a client was added - */ + * + * @return describes if a client was added + */ private def receiveNewClient(): Boolean = this.clientGetter.newClient() match case Some(c) => @@ -62,9 +65,9 @@ class Server(port: Int, maxClients: Int, val timeLimit: Int): false /** Sends `message` to all clients - * - * @param message the message to send - */ + * + * @param message the message to send + */ private def writeToAll(message: String): Unit = this.clients.mapAndRemove(c => val output = c.socket.getOutputStream |