blob: 4e525d0dfcafef595bf5897c8262613b0c391ec2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
function make_sockjs_client_transport (sock) {
var transport = {}
sock.onmessage = function (data) {
console.log('sockjs parse', data)
try {
var message = JSON.parse(data.data)
} catch (error) {
return console.log('error', error)
}
transport.onmessage(message)
}
transport.send = function (message) {
try {
var data = JSON.stringify(message)
} catch (error) {
return console.log('sockjs transport send error:', error)
}
sock.send(data)
}
return transport
}
|