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
case ConversationTimeout => | |
sessionHandler ! SessionTimeout(conversationID) | |
// This will also stop the event sourced actor | |
Behaviors.stopped |
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
private def idle(): ConversationBehavior = { | |
timers.startSingleTimer(TimerKey, ConversationTimeout, sessionTimeout) | |
this | |
} |
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
def postMessage(conversationID: ConversationID, sender: UserID, message: String)( | |
session: ActorRef[SessionCommand] | |
): Unit = | |
session ! PostMessage(conversationID, sender, message) |
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
onComplete(maybeSessionGranted) { | |
case Success(SessionGranted(session)) => | |
postMessage(conversationID, pmr.userID, pmr.message)(session) | |
complete(OK, PostMessageResponse(pmr.message)) | |
case Failure(_) => | |
complete(BadRequestError, "Authentication Failed") | |
case _ => complete(InternalServerError) | |
} |
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
def getSession(conversationID: ConversationID, userID: UserID): Future[SessionEvent] = | |
sessionHandler.ask(GetSession(conversationID, userID, _)) |
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
lazy val conversationRoutes: Route = { | |
concat( | |
pathPrefix(version / "conversation" / LongNumber) { conversationID => | |
post { | |
entity(as[PostMessageRequest]) { | |
pmr => | |
val maybeSessionGranted: Future[SessionEvent] = | |
getSession(conversationID, pmr.userID) | |
onComplete(maybeSessionGranted) { |
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 ConversationRoutes(sessionHandler: ActorRef[SessionHandlerCommand])(implicit | |
val system: ActorSystem[_] | |
) extends JsonSupport { ... } |
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
case class PostMessageRequest(userID: UserID, message: String) extends ConversationRestEntities | |
trait JsonSupport extends SprayJsonSupport with DefaultJsonProtocol { | |
implicit val postMessageRequestFormat = jsonFormat2(PostMessageRequest) | |
} |
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
<?xml version="1.0"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<artifactId>gameoflife</artifactId> | |
<groupId>com.wakaleo.gameoflife</groupId> | |
<version>1.0-SNAPSHOT</version> | |
</parent> | |
<groupId>com.wakaleo.gameoflife</groupId> | |
<artifactId>gameoflife-web</artifactId> |
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
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "CloudFormation template for testing", | |
"Metadata": { | |
"AWS::CloudFormation::Designer": { | |
"2042eff7-d31c-4904-afb0-4d2358ae7b40": { | |
"size": { | |
"width": 60, | |
"height": 60 | |
}, |