It looks like you're new here. If you want to get involved, click one of these buttons!
function calll(val)
{
//alert(val);
ws= new WebSocket("wss://websocket.kite.trade/?api_key=xxxx&user_id=yyyy&public_token=xyzw");
message = "{\"a\": \"mode\", \"v\": [\"ltp\", ["+val+"]]}";
// alert(message);
ws.binaryType = 'arraybuffer'
ws.send(message)
ws.onmessage = function (event) {
var dat=convert(event.data);
//alert(event.data);
// alert(dat);
if(dat.length>1)
{
var curr=0;
var count=(dat[1]) |
(dat[0] << 8);
// alert(count);
curr=curr+2;
for(i=0;i<count;i++)
{
var l=(dat[curr+1]) |
(dat[curr] << 8);
curr=curr+2;
var result = ((dat[curr+3]) |
(dat[curr+2] << 8) |
(dat[curr+1] << 16) |
(dat[curr] << 24));
// alert(result);
curr=curr+4;
var price = ((dat[curr+3]) |
(dat[curr+2] << 8) |
(dat[curr+1] << 16) |
(dat[curr] << 24));
curr=curr+4;
price=price/100;
//alert(result+","+price);
}
//alert(count+","+ByCount);
// alert(result);
}
//alert(makeInt(dat[11],dat[10],dat[9],dat[8]);
}
function convert(data) {
return new Uint8Array(data);
}
Here when i send 10 instruments token in val variable it shows alert of message properly
Once you subscribe you will get first tick post that you will only get ticks if the value changes.