Tictactoe web game - Demo for Akka and Xitrum
See slides: Develop realtime web with Scala and Xitrum
Requirement: Java 8+
Run:
sbt/sbt fgRun
Open http://localhost:8000/ or https://localhost:4430/
To generate Eclipse project:
sbt/sbt eclipse
Package:
sbt/sbt xitrumPackage
Directory target/xitrum
will be created:
target/xitrum/ config/ akka.conf xitrum.conf lib/ <jar files> script start start.bat
You can run a cluster of Tictactoe servers. See "Single node" and "Clustering" in Lobby.scala and Player.scala. Use akka.conf to config the cluster.
- Player actors connect to a lobby actor.
- When there are enough 2 players, the lobby actor let the player actors know about each other.
- The players then send messages directly to one another.
browser1 --- [SockJs] --- player actor1 | lobby actor | browser2 --- [SockJs] --- player actor2
browser1 --- [SockJs] --- player actor1 | | | browser2 --- [SockJs] --- player actor2
- Instead of letting player actors send messages directly to each other, use an intermediate game actor for each game.
- Let users other than the players watch games.
- Use Scala.js to convert game logic code written in Scala to JavaScript, to share game logic code between server side and client side.
- Use Akka FSM instead of
become
.