Hi All, I have some simple Actor:
case class Item(id: String, description: String)
object Player {
sealed trait PlayerMessage
case class PickupItem(item: Item)
case class GiveItem(itemId: String, player: ActorRef)
case object ShowInventory
def props(): Props =
Props(classOf[Player])
}
class Player extends Actor with ActorLogging {
import Player._
var inventory = Seq.empty[Item]
override def receive: Receive = {
case PickupItem(item) =>
inventory = inventory :+ item
case GiveItem(itemId, player) =>
inventory
.find(_.id == itemId)
.map { item =>
inventory = inventory.diff(Seq(item))
player ! PickupItem(item)
}
case ShowInventory =>
log.info(s"[${context.self.path.name}] [${inventory.mkString(", ")}]")
}
}
If two Player's actors live in two different remote actor systems - how
safely transfer item from one player to other (read transactionally or
guaranteed) change state of two actor, by design all actions with inventory
persisted to database (without akka-persistence).
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.