-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from rey/feature_restructure
Feature restructure
- Loading branch information
Showing
8 changed files
with
63 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
app_build | ||
_build |
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
var app = require('app'); | ||
var Tray = require('tray'); | ||
var Menu = require('menu'); | ||
var path = require('path'); | ||
var ping = require("net-ping") | ||
var BrowserWindow = require('browser-window'); | ||
|
||
var iconPath = path.join(__dirname, 'icon.png'); | ||
var appIcon = null; | ||
var win = null; | ||
|
||
app.on('ready', function(){ | ||
win = new BrowserWindow({show: false}); | ||
appIcon = new Tray(iconPath); | ||
var contextMenu = Menu.buildFromTemplate([ | ||
{ label: 'Quit', | ||
accelerator: 'Command+Q', | ||
selector: 'terminate:', | ||
} | ||
]); | ||
|
||
appIcon.setToolTip('This is my application.'); | ||
appIcon.setContextMenu(contextMenu); | ||
|
||
var count = 0; | ||
|
||
setInterval(function() { | ||
|
||
var target="8.8.8.8"; | ||
// var target="127.0.0.1"; | ||
var options = { | ||
timeout: 500 | ||
// timeout: 2000 | ||
}; | ||
|
||
var session = ping.createSession (options); | ||
session.pingHost (target, function (error, target, sent, rcvd) { | ||
|
||
var delta = rcvd - sent; | ||
|
||
// error | ||
if (error) { | ||
console.log ("🍎 " + target + " count: " + count + " error: " + error.toString ()); | ||
appIcon.setImage(__dirname + "/dead.png"); | ||
} | ||
|
||
// success | ||
else { | ||
console.log ("🍏 " + target + " count: " + count + " delta: " + delta + " sent: " + sent.getUTCMilliseconds() + " rcvd: " + rcvd.getUTCMilliseconds()); | ||
appIcon.setImage(__dirname + "/alive.png"); | ||
} | ||
|
||
count++; | ||
}); | ||
|
||
}, 1000); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.