Client is defined as:
@WebSocketClient(encoders = {MyMessageEncoder.class},
decoders={MyMessageDecoder.class})
public class MyClient {
@WebSocketOpen
public void onOpen(Session session) {
System.out.println("Connected to endpoint: " +
session.getRemote());
try {
MyMessage message = new MyMessage("{ \"foo\" : \"bar\"}");
session.getRemote().sendObject(message);
} catch (IOException | EncodeException ex) {
Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
//. . .
}
MyMessage is defined as:
public class MyMessage {
private JsonObject jsonObject;
public MyMessage() {
}
public MyMessage(String string) {
jsonObject = new JsonReader(new StringReader(string)).readObject();
}
//. . .
}
The above mentioned code works. But if { foo : "bar" } is used to
initialize MyMessage in the client then neither an exception is reported
on the client side nor the message is sent to the server.
Bug ?
Arun
--
http://twitter.com/arungupta
http://blogs.oracle.com/arungupta