I'm developing a web-socket application in play and using actor based websocket implementation according to their official tutorial (https://www.playframework.com/documentation/2.8.x/JavaWebSockets)
In controller
public WebSocket socket() {
System.out.println("socket connecton received");
return WebSocket.Text.accept(
request -> ActorFlow.actorRef(WebSocketActor::props, actorSystem, materializer));
}
WebSocketActor is implemented with Typed actors as below
public class WebSocketActor extends AbstractBehavior<String> {
But the issue is it is giving me following error Incompatible types: ActorRef is not convertible to ActorRef and it seems like ActorFlow.actorRef is only allows un-typed actors.
How can I use a Typed Actor with above implementation.
When there are missing APIs for typed (I think this is the case with the Play ActorFlow) you can adapt the new typed APIs to the classic ones using akka.actor.typed.javadsl.Adapter
, like so: Adapter.toClassic(typedActorRef)
More docs on coexisting typed and classic APIs here: https://doc.akka.io/docs/akka/current/typed/coexisting.html