Skip to content

Instantly share code, notes, and snippets.

@vishnuc
Created September 19, 2019 12:17
Show Gist options
  • Select an option

  • Save vishnuc/565142443891653238065113d6e8d211 to your computer and use it in GitHub Desktop.

Select an option

Save vishnuc/565142443891653238065113d6e8d211 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="author" content="">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js"></script>
</head>
<body>
<script>
var token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiJTSU1CVSIsInB1YmxpY0tleSI6ImFhOGMyYWQ4ODg3MjQ4NTUiLCJpYXQiOjE1Njg4ODY0OTksImV4cCI6MTU2ODk3Mjg5OX0.bRqeJU4xpmbH79P_dqsXF6UjJKMgty0zjg_cakhvGJA";
var data = {
"transports": [
"websocket",
],
"query": {
token: token,
userID: "SIMBU",
source: "WebApi",
publishFormat: "Json",
broadcastMode: "Full"
},
"reconnection": false,
"path": "/marketdata/socket.io",
"hostname": "103.69.169.10",
};
var url = "http://103.69.169.10:10521";
if (sockets = io(url, data), false) {
console.log(data);
}
sockets.on('connect', function () {
status("socket connected success", "green");
formdata =
'{ "userID": "SIMBU", "clientID": "SIMBU", "source": "WEB", "instruments": {"exchangeSegment":1,"exchangeInstrumentID":2885},{"exchangeSegment":1,"exchangeInstrumentID":22},{"exchangeSegment":2,"exchangeInstrumentID":44460},{"exchangeSegment":2,"exchangeInstrumentID":44461}, "marketDataPort": "1502" }';
$.ajax({
url: "http://103.69.169.10:10521/marketdata/instruments/subscription",
type: 'POST',
data: formdata,
headers: {
"Authorization": token
},
success: function (data) {
status("subscription success", "green");
console.log(data);
},
});
});
sockets.on('event', function (data) {console.log("some event"); });
sockets.on("1501-json-full",function(data){
console.log("1501 data is "+data);
});
sockets.on("1501-json-partial",function(data){
console.log("1501 data is "+data);
});
sockets.on("1502-json-full",function(data){
console.log("data is on full mode "+data);
});
sockets.on("1503-json-partial",function(data){
console.log("data is "+data);
});
// sockets.on("1504-json-full",function(data){
// console.log("1504 data is of Index "+data);
// });
sockets.on("1510-json-partial",function(data){
console.log("1510 data is "+data);
});
sockets.on('disconnect', function () { console.log("Disconnected");});
sockets.on("1502-json-partial",function(data){
console.log("1502-json-partial data is "+data);
});
//candle Data Event message for binary full and json both (full and partial)
sockets.on("1505-json-partial",function(data){
console.log("data is "+data);
});
//candle Data Event message for binary full and json both (full and partial)
sockets.on("1505-json-full",function(data){
console.log("data is "+data);
});
//candle Data Event message for binary full and json both (full and partial)
sockets.on("1505-binary-full",function(data){
console.log("data is "+data);});
function status(msg, color) {
$('<p style="color:' + color + ';">' + msg + '</p>').appendTo(".status").fadeOut(5000, function () {
$(this).remove();
});
}
</script>
<div class="status"></div>
<div class="logs"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment