Reputation: 45692
I want to store my websocket connection in cookies. I use $.cookie('ws', ws)
; in firebug ws looks like:
WebSocket {binaryType: "blob", extensions: "", protocol: "", onclose: function, onerror: null…}
URL: "wss://localhost:5432/"
binaryType: "blob"
bufferedAmount: 0
extensions: ""
onclose: function (m) {
onerror: null
onmessage: function (m) {
onopen: function () {
protocol: ""
readyState: 0
url: "wss://localhost:5432/"
__proto__: WebSocket
}
Problem:
When I get my websocket connection from cookies it looks like: [object WebSocket]
and I can't pull anything from it.
Question: How can I convert [object WebSocket]
to normal websocket object?
Upvotes: 0
Views: 94
Reputation: 175766
A cookie stores text, attempting to store an object will only store its string representation which is the useless character sequence "[object WebSocket]
".
Instead store the relevant (text) properties, read them back and reconstruct the object from scratch.
Upvotes: 2