Skip to content

Commit

Permalink
Changed the place where the string from the JSOn object commandType g…
Browse files Browse the repository at this point in the history
…ets extracted from the switch statement to variabel definition so that it can be used in the answer.
  • Loading branch information
RaHoni committed Oct 2, 2020
1 parent 7d47b34 commit 5a64dd4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/PrivateHome/UI/Websocket/websocket.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ object websocket {
val msgText = msg.asTextMessage.getStrictText
if (msgText.trim != "") { //In case some one sends an empty message only containing whitespaces because otherwise the execution fails without exception
val json = parse(msgText)
val commandType = json \ "Command"
val commandType = (json \ "Command").extract[String]
val args = json \ "Args"
val answer = commandType.extract[String] match {
val answer = commandType match {
case "on" => uiControl.receiveCommand(args.extract[commandOn])
case "off" => uiControl.receiveCommand(args.extract[commandOff])
case "getDevices" => uiControl.receiveCommand(args.extract[commandGetDevices])
Expand Down

0 comments on commit 5a64dd4

Please sign in to comment.