mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-28 00:09:13 +00:00
34 lines
952 B
Scala
34 lines
952 B
Scala
// Copyright (c) 2017 PSForever
|
|
package services
|
|
|
|
import akka.event.{ActorEventBus, SubchannelClassification}
|
|
import akka.util.Subclassification
|
|
import net.psforever.packet.game.PlanetSideGUID
|
|
|
|
object Service {
|
|
final val defaultPlayerGUID : PlanetSideGUID = PlanetSideGUID(0)
|
|
|
|
final case class Join(channel : String)
|
|
final case class Leave()
|
|
final case class LeaveAll()
|
|
}
|
|
|
|
trait GenericEventBusMsg {
|
|
def toChannel : String
|
|
}
|
|
|
|
class GenericEventBus[A <: GenericEventBusMsg] extends ActorEventBus with SubchannelClassification {
|
|
type Event = A
|
|
type Classifier = String
|
|
|
|
protected def classify(event: Event): Classifier = event.toChannel
|
|
|
|
protected def subclassification = new Subclassification[Classifier] {
|
|
def isEqual(x: Classifier, y: Classifier) = x == y
|
|
def isSubclass(x: Classifier, y: Classifier) = x.startsWith(y)
|
|
}
|
|
|
|
protected def publish(event: Event, subscriber: Subscriber): Unit = {
|
|
subscriber ! event
|
|
}
|
|
}
|