I am trying to send send data using json from client to server and vice versa.
In my socket when I receive the message I do not receive the json data.
Client:
var member ={
"firstName":"Ray",
"lastName":"Villalobos",
"joined":2012
};
ws = new WebSocket("ws://localhost:8080/echo");
ws.onopen = function(evt) { log("socket opened"); ws.send ('Data', member);};
Server:
@Override
public void onMessage(String text)
{
System.out.println("onMessage " + text);
Data data = new Gson().fromJson(text, Data.class);
System.out.println("onMessage " + data);
}
Does any body have any examples of how I can use json and websockets
Cheers
Charlie