score:1
Accepted answer
As is: WebSocket.acceptOrResult[JsValue, JsValue]
you expect your websocket to receive JsValue
.
This seems to match you code below in MessageActor
:
override def receive = {
case message: JsValue => // ...
}
However, you shouldn't expect the conversion from JsValue
to WSMessageIn
to happen without your intervention.
What you could do is simply:
override def receive = {
case message: JsValue =>
WSMessageIn.json2object(message) match {
case message: PostMessage =>
...
case message: MessageFromIn =>
...
}
}
You were probably expecting an implicitly conversion, you can get it by giving a hint to the compiler (i.e., saying what you expect):
override def receive = {
case message: JsValue =>
(message: WSMessageIn) match {
case message: PostMessage =>
...
case message: MessageFromIn =>
...
}
}
Note: you could turn abstract class WSMessageIn()
into: sealed trait WSMessageIn
Source: stackoverflow.com
Related Query
- An actor for websocket on play framework with multiple message type - scala
- Which is best data access options available for Play framework with Scala and PostgreSQL?
- Minimal framework in Scala for collections with inheriting return type
- Play Framework 2.4 Scala missing parameter type for implicit request in Action after ActionRefiner
- Scala Play WebSocket - One Actor, multiple message types
- Why scala cannot infer common return type for a function with multiple parameter lists?
- Play 2.4 create an actor for handle websocket with Guice
- Specify MIME type when downloading binary file with OK() in Play for Scala
- How to create multiple users in play framework 2.5.x with WebSocket
- Scala Play framework Forms, type not automatically inferred for a tuple parameter
- custom message properties in scala play framework for removing hard coded string
- Scala Play framework json serializer for generic type
- how to setup a for loop inside if statement with correct syntax Play framework Scala Template
- 2 MB file upload to AWS S3 fails with Play framework used for uploading multiple files
- SASS support for Play Framework with Scala 2.13
- WebSocket Missing implicit Message Flow Transformer for custom data type in play 2.6
- Play Framework 2.4 routing: one route for multiple urls Scala
- How to use cdn url with play framework and scala for image display?
- Scala with Play Framework 2.3.6: sending a message to all socket clients
- How to use IntelliJ with Play Framework and Scala
- How do I create a TestActorRef in Scala for an Actor with constructor params?
- Errors in Eclipse for Scala project generated by Play Framework
- Scala - can yield be used multiple times with a for loop?
- Json Serialization for Trait with Multiple Case Classes (Sum Types) in Scala's Play
- Dynamic SQL Parameters with Anorm and Scala Play Framework
- Play Scala No Json deserializer found for type (String, String). Try to implement an implicit Reads or Format for this type
- How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
- Play Framework for Scala - RESTful Web Service
- Conditional methods of Scala generic classes with restrictions for type parameters
- OAuth2 provider for Scalatra or Play framework in Scala
More Query from same tag
- scala and java io and sockets issue
- Scala map a Vector of tuples to vector of object
- Scala REPL "paste" mode doesn't exit on ctrl-D in Sublime Text 2
- How can I have an optional Sbt setting?
- Attaching sources in IntelliJ IDEA for scala project
- How to get multiple inputs into spark sql statement?
- Asymmetric table projection in Slick
- Spark Streaming using Scala to insert to Hbase Issue
- Attributes in XML literals only accept String?
- Coming to Scala from Java, should I use List or Buffer as a replacement for ArrayList
- Conditional trait mixins
- sbt not resolving dependency; path correct except ${package.type} extension
- Unable to run scalajs-react project
- How to write a nice Low-Pass-Filter in Scala
- How to create a graph from a CSV file using Graph.fromEdgeTuples in Spark Scala
- Heterogeneous arguments in a Scala function
- Scala - second-generation inheritance of a common trait
- sender() results in deadLetters for implementation but not in unit tests
- How to do multiplication by using successor and predecessor in Scala
- How to inject a service class into a Spec class with Play framework
- Scala: show systemDrive in TreeView
- How to receive a message within a specific case of a receive in Akka actors?
- In scala, check non nullity and apply method directly?
- How to use mesos master url in a self-contained Scala Spark program
- General enrichment providing "uncurried" in scala
- Problem with auxiliary constructors in Scala
- Adding aliases for macro annotations
- foldLeft on list of Doubles returns strange value
- Scala fold for RDD [String] acting wierd
- In DataFrame.withColumn, how can I check if the column's value is null as a condition for the second parameter?