Rewrote frontend download download function to make use of forked processes. This means that the download runs in full async (essentially in a separate thread). Updated the discord wrapper to be more dynamic. Updated auth manager to use async/await.

This commit is contained in:
Daniel Scalzi
2018-01-18 23:45:50 -05:00
parent 1d10b0209a
commit d4d7be7c47
5 changed files with 249 additions and 112 deletions

View File

@@ -3,16 +3,15 @@ const {Client} = require('discord-rpc')
const ConfigManager = require('./configmanager.js')
let rpc
let activity
exports.initRPC = function(genSettings, servSettings){
rpc = new Client({ transport: 'ipc' });
exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting for Client..'){
rpc = new Client({ transport: 'ipc' })
rpc.on('ready', () => {
const activity = {
// state = top text
// details = bottom text
activity = {
details: initialDetails,
state: 'Server: ' + servSettings.shortId,
details: 'Exploring the wall',
largeImageKey: servSettings.largeImageKey,
largeImageText: servSettings.largeImageText,
smallImageKey: genSettings.smallImageKey,
@@ -33,8 +32,18 @@ exports.initRPC = function(genSettings, servSettings){
})
}
exports.updateDetails = function(details){
if(activity == null){
console.error('Discord RPC is not initialized and therefore cannot be updated.')
}
activity.details = details
rpc.setActivity(activity)
}
exports.shutdownRPC = function(){
if(!rpc) return
rpc.setActivity({})
rpc.destroy()
rpc = null
activity = null
}