scalaakkascala.jsstunice

Reactive and concurrent game between two nods over the network


I implemented two player pong game using scala and scalajs,sofar I can play as two players using 4 different keys and now I'm looking to run it between two pc over the network.Any suggestions for reactive and concurrent tools to do that ?


Solution

    1. Perhaps, you would need Reactive Streams and their Back-pressure protocol to not crash the server, when clients send too many requests. Basically, you would be able to specify different strategies for your server event consumer.

    2. Web-Socket would be handy as well. Your Scala.js code would send messages to server over WS

    I would recommend Akka-Streams: https://doc.akka.io/docs/akka-http/current/server-side/websocket-support.html

    or Http4s-fs2 https://github.com/http4s/http4s/blob/master/examples/blaze/src/main/scala/com/example/http4s/blaze/BlazeWebSocketExample.scala