aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/Server/ConnectionGetter.scala
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-17 13:45:44 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-17 13:45:44 +0200
commit4de67b497e0e229fe4a42f66f833640b6e50fd5a (patch)
tree34fb5b0e776f7cd3adcb4556f4d6a7c8ad66de39 /src/main/scala/Server/ConnectionGetter.scala
parent8595e892abc0e0554f589ed2eb88c351a347fbd4 (diff)
downloadscalevalapokalypsi-4de67b497e0e229fe4a42f66f833640b6e50fd5a.tar.gz
scalevalapokalypsi-4de67b497e0e229fe4a42f66f833640b6e50fd5a.zip
Moved the project to an IDEA project & wrote part of README.txt
Diffstat (limited to 'src/main/scala/Server/ConnectionGetter.scala')
-rw-r--r--src/main/scala/Server/ConnectionGetter.scala25
1 files changed, 0 insertions, 25 deletions
diff --git a/src/main/scala/Server/ConnectionGetter.scala b/src/main/scala/Server/ConnectionGetter.scala
deleted file mode 100644
index b3246a7..0000000
--- a/src/main/scala/Server/ConnectionGetter.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-package o1game.Server
-
-import java.io.IOException
-import java.net.{ServerSocket, Socket}
-import scala.concurrent.Future
-import scala.util.{Failure, Success}
-import scala.concurrent.ExecutionContext.Implicits.global
-
-/** Small helper class for getting new connections using futures */
-class ConnectionGetter(val socket: ServerSocket):
-
- private var nextClient: Future[Socket] = Future.failed(IOException())
-
- /** Returns a new socket to a client if there is any new connections. */
- def newClient(): Option[Socket] =
- this.nextClient.value match
- case Some(Success(s)) =>
- nextClient = Future(socket.accept())
- Some(s)
- case Some(Failure(e)) =>
- nextClient = Future(socket.accept())
- None
- case None => None
-
-end ConnectionGetter