Quantcast
Channel: GlassFish Related Items on Java.net
Viewing all articles
Browse latest Browse all 1091

Gizzly Websocket how to use google json sending and receiving both from client and server

$
0
0

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


Viewing all articles
Browse latest Browse all 1091

Trending Articles