How can I send my collection of objects and extract it from evt.data at client side ?

Jul 20, 2012 at 7:40 AM

Hi,

In the below code snippet, evt.data is returning a string . How can I receive a collection of custom objects ? 

ws -- > web socket connection instance.

 ws.onmessage = function (evt) 
     { 
        var received_msg = evt.data;
        alert("Message is received...");
     };

 

WebSocketSession object has a method SendResponseAsync with two overloads.

1. Takes only string.

2. strings and Param -> array of objects.

 

If I use the second overload, then how can I send my collection of objects and extract it from evt.data at client side ?

 

 

 

Thank you.

Coordinator
Jul 20, 2012 at 7:46 AM

Server:

Serialize your object to JSON string (by JSON.NET) then send the string to client.

send(string, param) = send(string.format(string, param))

Browser:

http://en.wikipedia.org/wiki/JSON