more efficient round events versioning
This commit is contained in:
parent
8683dba6a0
commit
637c824c59
|
@ -24,15 +24,17 @@ private[round] final class History(ttl: Duration) extends Actor {
|
|||
else ((v + 1 to version).toList map get).flatten.some
|
||||
)
|
||||
|
||||
case AddEvent(event) ⇒ {
|
||||
version = version + 1
|
||||
sender ! VersionedEvent(
|
||||
version = version,
|
||||
typ = event.typ,
|
||||
data = event.data,
|
||||
only = event.only,
|
||||
owner = event.owner,
|
||||
watcher = event.watcher) ~ { events.put(version, _) }
|
||||
case AddEvents(events) ⇒ sender ! {
|
||||
events map { e ⇒
|
||||
version = version + 1
|
||||
VersionedEvent(
|
||||
version = version,
|
||||
typ = e.typ,
|
||||
data = e.data,
|
||||
only = e.only,
|
||||
owner = e.owner,
|
||||
watcher = e.watcher) ~ { events.put(version, _) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,9 +107,7 @@ private[round] final class Socket(
|
|||
})
|
||||
|
||||
def notify(events: Events) {
|
||||
(events map { event ⇒
|
||||
history ? AddEvent(event) mapTo manifest[VersionedEvent]
|
||||
}).sequence foreach { vevents ⇒
|
||||
history ? AddEvents(events) mapTo manifest[List[VersionedEvent]] foreach { vevents =>
|
||||
members.values foreach { m ⇒ batch(m, vevents) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ case class GetGameVersion(gameId: String)
|
|||
case object GetVersion
|
||||
case class GetEventsSince(version: Int)
|
||||
case class MaybeEvents(events: Option[List[VersionedEvent]])
|
||||
case class AddEvent(event: Event)
|
||||
case class AddEvents(events: List[Event])
|
||||
case object ClockSync
|
||||
case class IsConnectedOnGame(gameId: String, color: Color)
|
||||
case class IsGone(gameId: String, color: Color)
|
||||
|
|
Loading…
Reference in a new issue