diff --git a/akka-docs/scala/tutorial-chat-server.rst b/akka-docs/scala/tutorial-chat-server.rst index 4a10af9a45..73f66cc394 100644 --- a/akka-docs/scala/tutorial-chat-server.rst +++ b/akka-docs/scala/tutorial-chat-server.rst @@ -1,4 +1,4 @@ -Tutorial: write a scalable, fault-tolerant, persistent network chat server and client (Scala) +Tutorial: write a scalable, fault-tolerant, network chat server and client (Scala) ============================================================================================= .. sidebar:: Contents @@ -87,12 +87,53 @@ We will try to write a simple chat/IM system. It is client-server based and uses We will use many of the features of Akka along the way. In particular; Actors, fault-tolerance using Actor supervision, remote Actors, Software Transactional Memory (STM) and persistence. -But let's start by defining the messages that will flow in our system. +Creating an Akka SBT project +---------------------------- + +First we need to create an SBT project for our tutorial. You do that by stepping into the directory you want to create your project in and invoking the ``sbt`` command answering the questions for setting up your project:: + + $ sbt + Project does not exist, create new project? (y/N/s) y + Name: Chat + Organization: Hakkers Inc + Version [1.0]: + Scala version [2.9.0.RC1]: + sbt version [0.7.6.RC0]: + +Add the Akka SBT plugin definition to your SBT project by creating a ``Plugins.scala`` file in the ``project/plugins`` directory containing:: + + import sbt._ + + class Plugins(info: ProjectInfo) extends PluginDefinition(info) { + val akkaRepo = "Akka Repo" at "http://akka.io/repository" + val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1-M1" + } + +Create a project definition ``project/build/Project.scala`` file containing:: + + import sbt._ + + class ChatProject(info: ProjectInfo) extends DefaultProject(info) with AkkaProject { + val akkaRepo = "Akka Repo" at "http://akka.io/repository" + val akkaSTM = akkaModule("stm") + val akkaRemote = akkaModule("remote") + } + + +Make SBT download the dependencies it needs. That is done by invoking:: + + > reload + > update + +From the SBT project you can generate files for your IDE: + +- `SbtEclipsify `_ to generate the Eclipse project. Detailed instructions are available in :ref:`getting-started-first-scala-eclipse`. +- `sbt-idea `_ to generate the Eclipse project Creating messages ----------------- -It is very important that all messages that will be sent around in the system are immutable. The Actor model relies on the simple fact that no state is shared between Actors and the only way to guarantee that is to make sure we don't pass mutable state around as part of the messages. +Let's start by defining the messages that will flow in our system. It is very important that all messages that will be sent around in the system are immutable. The Actor model relies on the simple fact that no state is shared between Actors and the only way to guarantee that is to make sure we don't pass mutable state around as part of the messages. In Scala we have something called `case classes `_. These make excellent messages since they are both immutable and great to pattern match on.