Skip to content

Commit

Permalink
Update 2.5.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
NyboTV committed Jul 31, 2022
1 parent 706cb0b commit 0084dcc
Show file tree
Hide file tree
Showing 6 changed files with 487 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/bin/config/cfg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.5.5",
"version": "2.5.5.1",
"refreshInterval": 100,
"debug": false,
"firstInstall": true
Expand Down
2 changes: 1 addition & 1 deletion src/bin/config/usercfg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Basics": {
"currency": "EUR",
"unit": "Kilometer",
"unit": "Miles",
"weight": "Tons",
"temp": "Celsius",
"timeFormat": "EU"
Expand Down
9 changes: 6 additions & 3 deletions src/bin/modules/states/truck.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ const truckStates = async (TPClient, refreshInterval, telemetry_path, logIt, tim
Odometer = Math.floor(Odometer / 1.609344)
}

console.log(Odometer)
var data = {
id: "Nybo.ETS2.Dashboard.Odometer",
value: `${Odometer}`
Expand All @@ -497,7 +496,7 @@ const truckStates = async (TPClient, refreshInterval, telemetry_path, logIt, tim
states.push(data)
}

if(Speed !== SpeedOld || offline === true) {
if(Speed !== SpeedOld || unit !== unitOld || offline === true) {
SpeedOld = Speed

if(unit === "miles") {
Expand Down Expand Up @@ -633,9 +632,13 @@ const truckStates = async (TPClient, refreshInterval, telemetry_path, logIt, tim
states.push(data_event)
}

if(Fuel !== FuelOld || offline === true) {
if(Fuel !== FuelOld || unit !== unitOld || offline === true) {
FuelOld = Fuel

if(unit === "miles") {
Fuel = Math.floor(Fuel / 3.785)
}

var data = {
id: "Nybo.ETS2.Dashboard.Fuel",
value: `${Fuel}`
Expand Down
45 changes: 25 additions & 20 deletions src/bin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ let open_settings = false
let frame = false
let version = ""

var ping = false

let notificationShowed = false
let NOTIFICATION_TITLE = ''
let NOTIFICATION_BODY = ''
Expand Down Expand Up @@ -69,10 +71,6 @@ if(debugMode) {
telemetry_path = "./tmp"
}

if(OfflineMode) {
console.log("LOL")
}

// Checks and creates if neccessary Logs Folder
if(fs.existsSync(`./logs`)) { } else { fs.mkdirSync(`./logs`) }

Expand Down Expand Up @@ -561,21 +559,23 @@ const webinterface = async (config, uConfig) => {
}

async function cur_user_online () {

serverPing()
setInterval(() => {
serverPing()
}, 60000);

for (var i = 0; i < Infinity; await timeout(10000), i++) {
axios.get('http://82.165.69.157:5000/ets2_plugin')
for (var i = 0; i < Infinity; await timeout(30000), i++) {
ping = await serverPing(ping)
console.log(ping)
if(ping) {
axios.get('http://82.165.69.157:5000/ets2_plugin')
.then(response => {
response = response.data
cur_user = response.current_user
})
.catch(e => {
logIt("ERROR", "An Error Appeared! " + e)
cur_user = "Server Offline"
})
} else {
cur_user = "Server Offline"
}
}
}

Expand Down Expand Up @@ -914,15 +914,20 @@ async function getVersion() {
})
}

function serverPing () {
axios.get('http://82.165.69.157:5000/')
.then(response => {
if(debugMode) { logIt("API", "Server Ping successfull") }
return
})
.catch(e => {
logIt("ERROR", "An Error Appeared! " + e)
return
function serverPing() {
return new Promise(async (resolve, reject) => {
axios.get('http://82.165.69.157:5000/')
.then(response => {
if(debugMode) { logIt("API", "Server Ping successfull") }
resolve(true)
ping = true
})
.catch(e => {
if(ping) {
logIt("ERROR", e)
}
resolve(false)
})
})
}

Expand Down
Loading

0 comments on commit 0084dcc

Please sign in to comment.