Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
Websockets now work adding new agents
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyjones committed Nov 15, 2013
1 parent 902f543 commit 69c0def
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion BEE Client/etc/config.js.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var config = {};

config.hiveIP = '25.199.138.99';
config.hiveIP = '127.0.0.1';
config.intervalTimeout = 20000;


Expand Down
2 changes: 1 addition & 1 deletion Queen/config/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var config = {};

config.hiveIP = '192.168.1.106';
config.hiveIP = '127.0.0.1';
config.serverPort = 3000;

module.exports = config;
19 changes: 12 additions & 7 deletions Queen/public/scripts/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ var socket = io.connect();
var totalAgents = 0;

function addAgent(agent, firstLoad) {
$("#agent-table").append('<tr id=' + agent.id + '>' +
'<th><a href=/agents/' + agent.id + '>' +
agent.id + '</a></th>' +
console.log("AGENT:");
console.log(agent);
$("#agent-table").append('<tr id=' + agent.UUID + '>' +
'<th><a href=/agents/' + agent.UUID + '>' +
agent.UUID + '</a></th>' +
'<th>' + agent.machineid +'</th>' +
'<th><button class="btn btn-default" ' +
'onclick="setAgentOffline(' + agent.id +
'onclick="setAgentOffline(' + agent.UUID +
')">×</button></th></div>');

totalAgents += 1;
Expand Down Expand Up @@ -55,7 +57,12 @@ function newAgent() {
* Sockets
*/
socket.on('agent', function(data) {
addAgent(data.agent);
console.log(data);
var value = null;
for(var key in data) {
value = data[key];
}
addAgent(value);
});

socket.on('offline', function(data) {
Expand All @@ -65,8 +72,6 @@ socket.on('offline', function(data) {
socket.on('init', function(data) {
console.log(data);
for (var agent in data.data) {
// Set the id field to send through as one object
data.data[agent].id = agent
console.log(data.data[agent])
addAgent(data.data[agent], true);
}
Expand Down

0 comments on commit 69c0def

Please sign in to comment.