diff --git a/src/background.js b/src/background.js index fb36495..bbc5e34 100644 --- a/src/background.js +++ b/src/background.js @@ -1,10 +1,13 @@ 'use strict' -import { app, protocol, BrowserWindow } from 'electron' +import { app, protocol, BrowserWindow, ipcMain } from 'electron' import { createProtocol } from 'vue-cli-plugin-electron-builder/lib' import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer' +import path from 'path' const isDevelopment = process.env.NODE_ENV !== 'production' +import { start, status, stop, state, sub } from './utils/server' + // Scheme must be registered before the app is ready protocol.registerSchemesAsPrivileged([ { scheme: 'app', privileges: { secure: true, standard: true } } @@ -13,13 +16,14 @@ protocol.registerSchemesAsPrivileged([ async function createWindow() { // Create the browser window. const win = new BrowserWindow({ - width: 800, - height: 600, + width: 1280, + height: 720, webPreferences: { // Use pluginOptions.nodeIntegration, leave this alone // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info - nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION + nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION, + preload: path.join(__dirname, 'preload.js') } }) @@ -32,6 +36,11 @@ async function createWindow() { // Load the index.html when not in development win.loadURL('app://./index.html') } + + const test = (data) => { + win.webContents.send('test', JSON.stringify(data)) + } + sub.push(test) } // Quit when all windows are closed. @@ -78,3 +87,19 @@ if (isDevelopment) { }) } } + +ipcMain.handle('state', async (e, arg) => { + state(JSON.parse(arg)) +}) + +ipcMain.handle('status', async () => { + return status() +}) + +ipcMain.handle('server', async (e, arg) => { + if (arg === true) { + start() + } else { + stop() + } +}) \ No newline at end of file diff --git a/src/components/Events.vue b/src/components/Events.vue index 76e4db1..5ab50a8 100644 --- a/src/components/Events.vue +++ b/src/components/Events.vue @@ -43,6 +43,11 @@ export default { name.value = e.name } + const reset = () => { + item.value = '' + name.value = '' + } + const form = () => { if (item.value !== '') { update('events', item.value, { @@ -53,13 +58,13 @@ export default { name: name.value, }) } + reset() } const delForm = () => { if (item.value) { del('events', item.value) - item.value = '' - name.value = '' + reset() } } diff --git a/src/components/Matches.vue b/src/components/Matches.vue index bf3ad23..6990d35 100644 --- a/src/components/Matches.vue +++ b/src/components/Matches.vue @@ -56,9 +56,9 @@

Best Of

-

Series Score

- -

Game Scores

+ + + diff --git a/src/store.js b/src/store.js index c9c75ec..f274708 100644 --- a/src/store.js +++ b/src/store.js @@ -13,6 +13,9 @@ const state = reactive({ casters: [], hosts: [], streams: [], + streamsFull: [], + overlayStream: null, + server: false, }) const methods = { diff --git a/src/utils/websocket.js b/src/utils/websocket.js index ff6aa02..0cc53e8 100644 --- a/src/utils/websocket.js +++ b/src/utils/websocket.js @@ -1,4 +1,5 @@ import store from '../store' +import { sendAll } from './server' const events = [ 'create', @@ -18,6 +19,7 @@ const channels = [ const channelEvents = [ 'info', + 'streams:full', ] channels.forEach((x) => { @@ -31,11 +33,16 @@ export const handleMsg = (msg) => { const ev = msg.event.split(':') const c = ev[0] const e = ev[1] + console.log(c, e) if (e === 'read') { store.state[c] = msg.data + } else if (e === 'full') { + store.state.streamsFull = msg.data + console.log(msg.data) + sendAll() } } else { - console.warn('received unkown event!', msg) + console.warn('received unknown event!', msg) } } @@ -46,6 +53,9 @@ export const sendSub = (ws) => { } ws.send(JSON.stringify(d)) }) + ws.send(JSON.stringify({ + subscribe: `streams:full` + })) } export const create = (channel, data) => { diff --git a/src/views/Home.vue b/src/views/Home.vue index 53dd1c3..06ea495 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -12,7 +12,21 @@ APL Logo
-
Coming soon
+
+

Welcome, Ayush

+

Select Stream for ingame overlay

+ + + +
@@ -24,6 +38,7 @@