feat(ui): Websocket
Started implementing functionality to Websocket.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package model.sessions
|
||||
|
||||
import de.knockoutwhist.utils.events.SimpleEvent
|
||||
import logic.game.GameLobby
|
||||
import org.apache.pekko.actor.{Actor, ActorRef}
|
||||
import play.api.libs.json.{JsObject, JsValue, Json}
|
||||
import util.WebsocketEventMapper
|
||||
@@ -27,6 +28,7 @@ class UserWebsocketActor(
|
||||
Try {
|
||||
jsonObject match {
|
||||
case Success(value) =>
|
||||
println("SUCCESS, RECEIVED SUCCESSFUL MESSAGE..." + jsonObject)
|
||||
handle(value)
|
||||
case Failure(exception) =>
|
||||
transmitTextToClient(s"Error parsing JSON: ${exception.getMessage}")
|
||||
@@ -86,12 +88,12 @@ class UserWebsocketActor(
|
||||
}
|
||||
}
|
||||
|
||||
def transmitJsonToClient(jsonObj: JsObject): Unit = {
|
||||
def transmitJsonToClient(jsonObj: JsValue): Unit = {
|
||||
transmitTextToClient(jsonObj.toString())
|
||||
}
|
||||
|
||||
def transmitEventToClient(event: SimpleEvent): Unit = {
|
||||
transmitJsonToClient(WebsocketEventMapper.toJson(event))
|
||||
def transmitEventToClient(event: SimpleEvent, gameLobby: GameLobby): Unit = {
|
||||
transmitJsonToClient(WebsocketEventMapper.toJson(event, gameLobby))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user