I implemented an WebSocketController
http://www.playframework.org/documentation/1.2.3/asynchronous#UsingWebSockets
, similar to the one in the Play Framework tutorial, but it doesn't
receive any messages from the client. Have I done anything wrong?
Here is my WebSocketController:
public class TestSocket extends WebSocketController {
public static void hello(String name) {
while(inbound.isOpen()) {
WebSocketEvent evt = await(inbound.nextEvent());
if(evt instanceof WebSocketFrame) {
WebSocketFrame frame = (WebSocketFrame)evt;
System.out.println("received: " + frame.getTextData());
if(!frame.isBinary()) {
if(frame.getTextData().equals("quit")) {
outbound.send("Bye!");
disconnect();
} else {
outbound.send("Echo: %s", frame.getTextData());
}
}
} else if(evt instanceof WebSocketClose) {
System.out.println("socket closed");
}
}
}
}
I have also posted this question on StackOverflow, including a client:
http://stackoverflow.com/questions/7919856/how-to-use-websockets-with-play-framework