I want to get live locations through socket connection. I am not able to receive it
I tried this example: https://github.com/traccar/traccar-web/blob/master/web/simple/app.js
I set my url and token into this but it is not working for me.
So i tried jquery ajax for session api
$.ajax({
url: "{host}/api/session",
dataType: "json",
type: "POST",
data: {
email: "username",
password: "password"
},
success: function(sessionResponse){
console.log(sessionResponse);
}
});
this is giving me set-cookie
header in response..
So after successfull session api i tried this for socket connection but it is always failing
var socket = new WebSocket('ws' + url.substring(4) + '/api/socket');
socket.onclose = function (event) {
console.log('socket closed');
};
socket.onmessage = function (event) {
var data = JSON.parse(event.data);
console.log(data);
};
How can i establish socket connection after successfull session api request.?
I want to get live locations through socket connection. I am not able to receive it
I tried this example: https://github.com/traccar/traccar-web/blob/master/web/simple/app.js
I set my url and token into this but it is not working for me.
So i tried jquery ajax for session api
$.ajax({ url: "{host}/api/session", dataType: "json", type: "POST", data: { email: "username", password: "password" }, success: function(sessionResponse){ console.log(sessionResponse); } });
this is giving me
set-cookie
header in response..So after successfull session api i tried this for socket connection but it is always failing
var socket = new WebSocket('ws' + url.substring(4) + '/api/socket'); socket.onclose = function (event) { console.log('socket closed'); }; socket.onmessage = function (event) { var data = JSON.parse(event.data); console.log(data); };
How can i establish socket connection after successfull session api request.?