Commit e685137e authored by PD0ZRY Rudy's avatar PD0ZRY Rudy
Browse files

this is how we generate our shit.

parent aa6e1b6f
node_modules
......@@ -5,23 +5,27 @@ var options = {
var activeCallCount = 0
var activeCalls = {}
var dup = false
var socket = require('socket.io-client')('bm-lastheard.pi9noz.ampr.org',options);
socket.on('connect', function(){
activeCallCount = 0
activeCalls = {}
dup = false
console.log("Connected")
socket.on('mqtt', function (msg) {
var data = JSON.parse(msg.payload);
if (data['Event'] == "Session-Start")
if (data['Event'] == "Session-Start" && data['Stop'] == 0)
{
activeCallCount++
if (activeCalls[data['SessionID']] != undefined) dup = true
activeCalls[data['SessionID']] = data
redrawDisplay()
if (dup) console.log("Duplicated session")
}
if (data['Stop'] != 0)
{
if (activeCalls[data['SessionID']] != undefined)
{
activeCallCount--
delete(activeCalls[data['SessionID']])
redrawDisplay()
}
......@@ -31,12 +35,16 @@ socket.on('connect', function(){
socket.on('event', function(data){
console.log(data)
});
socket.on('disconnect', function(){});
socket.on('disconnect', function(){
activeCallCount = 0
activeCalls = {}
dup = false
});
function redrawDisplay()
{
console.log('\033[2J');
console.log("Session count: " + activeCallCount);
console.log("Session count: " + Object.keys(activeCalls).length);
console.log("Sessions:");
for (index in activeCalls) {
console.log(index + " " + activeCalls[index]['SourceCall'] + "\t" + activeCalls[index]['SourceID'] + "\t->\t"+activeCalls[index]['DestinationID'] + "\t\t"+activeCalls[index]['LinkName']);
......
var options = {
'path':'/lh',
'secure':true
}
var activeCallCount = 0
var activeCalls = {}
var dup = false
var CLI = require('clui'),
clc = require('cli-color');
var Line = CLI.Line,
LineBuffer = CLI.LineBuffer;
var outputBuffer = new LineBuffer({
x: 0,
y: 0,
width: 'console',
height: 'console'
});
var socket = require('socket.io-client')('bm-lastheard.pi9noz.ampr.org',options);
socket.on('connect', function(){
activeCallCount = 0
activeCalls = {}
dup = false
console.log("Connected")
socket.on('mqtt', function (msg) {
var data = JSON.parse(msg.payload);
if (data['Event'] == "Session-Start" && data['Stop'] == 0)
{
if (activeCalls[data['SessionID']] != undefined) {
dup = true
return
}
activeCalls[data['SessionID']] = data
redrawDisplay()
if (dup) console.log("Duplicated session")
}
if (data['Stop'] != 0)
{
if (activeCalls[data['SessionID']] != undefined)
{
delete(activeCalls[data['SessionID']])
redrawDisplay()
}
}
})
});
socket.on('event', function(data){
});
socket.on('disconnect', function(){
activeCallCount = 0
activeCalls = {}
dup = false
});
function redrawDisplay()
{
console.log('\033[2J');
var outputBuffer = new LineBuffer({
x: 0,
y: 0,
width: 'console',
height: 'console'
});
var message = new Line(outputBuffer)
.column('LH CLI', 20, [clc.green])
.fill()
.store();
var message = new Line(outputBuffer)
.column('Session count: '+Object.keys(activeCalls).length, 20, [clc.green])
.fill()
.store();
var header = new Line(outputBuffer)
.column('',4)
.column('Session ID', 37, [clc.cyan])
.column('Source', 20, [clc.cyan])
.column('Destination', 20, [clc.cyan])
.column('LinkName', 25, [clc.cyan])
.fill()
.store();
for (index in activeCalls) {
var reflector = ""
if (activeCalls[index]['ReflectorID']) reflector = "("+activeCalls[index]['ReflectorID']+")"
line = new Line(outputBuffer)
.column((Math.floor(Date.now() / 1000) - activeCalls[index]['Start']) + '',4)
.column(index, 37)
.column(activeCalls[index]['SourceCall'] + " (" + activeCalls[index]['SourceID'] + ")", 20)
.column(activeCalls[index]['DestinationID']+" "+reflector, 20)
.column(activeCalls[index]['LinkName'], 25)
.fill()
.store();
}
outputBuffer.output();
}
{ "name" : "Brandmeister-LH-CLI"
, "version" : "1.0.0"
, "dependencies" : { "socket.io-client": ""
, "clui":""
, "cli-color":""}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment