2014-06-27 01:52:25 +04:00
|
|
|
var ws = undefined;
|
|
|
|
|
|
|
|
function do_ida_socket(callme) {
|
2014-06-30 18:31:16 +04:00
|
|
|
if (ws == undefined || ws.readyState == WebSocket.CLOSED) {
|
2014-06-27 01:52:25 +04:00
|
|
|
ws = new WebSocket('ws://localhost:3003', 'qira');
|
2015-03-17 08:13:53 +03:00
|
|
|
ws.onerror = function(e) {
|
|
|
|
// TODO: why doesn't this catch the "net::ERR_CONNECTION_REFUSED"?
|
2015-08-11 13:27:23 +03:00
|
|
|
// hmm, it looks like it does, but error is still printed to console
|
2015-03-17 08:13:53 +03:00
|
|
|
};
|
2014-06-30 18:31:16 +04:00
|
|
|
ws.onopen = function() {
|
|
|
|
p('connected to IDA socket');
|
|
|
|
callme();
|
|
|
|
};
|
2014-06-27 01:52:25 +04:00
|
|
|
ws.onmessage = function(msg) {
|
|
|
|
//p(msg.data);
|
|
|
|
var dat = msg.data.split(" ");
|
|
|
|
if (dat[0] == "setiaddr") {
|
2014-08-21 04:45:09 +04:00
|
|
|
Session.set("iaddr", dat[1]);
|
2014-07-15 04:49:18 +04:00
|
|
|
Session.set("dirtyiaddr", true);
|
2014-06-27 01:52:25 +04:00
|
|
|
}
|
|
|
|
if (dat[0] == "setdaddr") {
|
2014-08-21 04:45:09 +04:00
|
|
|
if (get_data_type(dat[1]) != "datainstruction") {
|
|
|
|
update_dview(dat[1]);
|
2014-07-15 05:32:01 +04:00
|
|
|
}
|
2014-06-27 01:52:25 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
callme();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 22:15:56 +04:00
|
|
|
Deps.autorun(function() { DA("send setaddress to ida");
|
2014-06-27 01:52:25 +04:00
|
|
|
var iaddr = Session.get('iaddr');
|
|
|
|
do_ida_socket(function() {
|
2014-09-09 16:28:09 +04:00
|
|
|
cmd = 'setaddress '+iaddr;
|
|
|
|
try {
|
|
|
|
ws.send(cmd);
|
|
|
|
} catch(err) {
|
|
|
|
// nothing
|
|
|
|
}
|
2014-06-27 01:52:25 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|