Created
October 16, 2013 16:19
-
-
Save stevef/7010599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ScoresStream extends Actor with akka.actor.ActorLogging { | |
//log.info("We've got yet another pigdog on our hands") | |
var members = Set.empty[String] | |
val (scoresEnumerator, scoresChannel) = Concurrent.broadcast[JsValue] | |
case class Message(kind: String, user: String, message: String) | |
implicit val messageReads = Json.reads[Message] | |
implicit val messageWrites = Json.writes[Message] | |
val sub = new Sub(scoresChannel) | |
val pub = new Pub | |
def receive = { | |
case Join(teamId) => { | |
sub.sub("tsn-test-channel") | |
sender ! Connected(scoresEnumerator) | |
} | |
case Talk(username, text) => { | |
log.info("getting talk for username: " + username + "and text: " + text) | |
notifyAll("talk", username, text) | |
} | |
case _ => println("wuts going on here?") | |
} | |
def notifyAll(kind: String, user: String, text: String) { | |
val msg = Message(kind, user, text) | |
//chatChannel.push(msg) | |
//Pub to Redis | |
pub.sendChatMsg(Json.stringify(messageWrites.writes(msg))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment