-
-
Save NirLevanon-zz/eba05516f512d1d043af 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
| import play.api.libs.json.{Json, Writes} | |
| trait RabbitMessage { | |
| val command: String | |
| } | |
| object ActivateMessage { | |
| implicit val tjs: Writes[ActivateMessage] = Json.writes[ActivateMessage] | |
| } | |
| case class ActivateMessage(Id:String, command:String="activate") extends RabbitMessage | |
| def publishToRMQ[T <: RabbitMessage](deviceId: String, toRMQRabbitMessage: T)(implicit writer: Writes[T]) = | |
| publishString(writer.writes(toRMQRabbitMessage).toString, getToRMQRoutingKey(deviceId, toRMQRabbitMessage.command)) | |
| sealed case class SendMessage[T <: RabbitMessage](Id: String, message: T)(implicit writer: Writes[T]) | |
| when(Idle){ | |
| case Event(SendMessage(Id, message)(writes),_) => { | |
| log.info(s"sending RMQ message: $message") | |
| publishToRMQ(Id, message)(writes) | |
| goto(AwaitRMQResponse$) using AwaitRMQResponseData(sender) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment