From: Enrique Hernandez Date: Thu, 17 Dec 2020 17:50:03 +0000 (-0600) Subject: stream path animation v4 X-Git-Tag: v0.9~123^2 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=1627e07964a84723aaa8ddf646ebe1e24f1d42a8;p=mime-chat stream path animation v4 update input items styling add ipc event handler for message add send-message ipc handler add audio to send-message ipc remove extra JSON stringify statement for audio message add render bug fix for add contacts --- diff --git a/src/background.ts b/src/background.ts index 6b1284a..2892aa3 100644 --- a/src/background.ts +++ b/src/background.ts @@ -8,22 +8,15 @@ import * as path from "path"; import { SpeechRecorder } from "speech-recorder"; // TODO: connect To Crimata-BE -// import WebSocket from "ws"; +import WebSocket from "ws"; -// const ws = new WebSocket("ws://localhost:8080"); -// ws.on("open", function open() { -// ws.send("hello fro client"); -// }); -// ws.on("message", (message: any) => { -// console.log("received message", message); -// }); -// // const recorder = new SpeechRecorder({ sampleRate: 16000, framesPerBuffer: 320 }); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let win: BrowserWindow | null; +let ws: any; // Scheme must be registered before the app is ready protocol.registerSchemesAsPrivileged([ @@ -56,44 +49,35 @@ function createWindow() { win.loadURL("app://./index.html"); } - win.webContents.on('did-finish-load', () => { - // ipcMain.on('audio-stream', (Event: any, Payload: any) => { - // if (Payload.stream) { - // console.log('begin streaming'); - // recorder.start({ - // onAudio: (audio: object, speech: boolean) => { - // console.log(audio) - // } - // }); - // } else { - // recorder.stop(); - // console.log('stop streaming') - // } - // }) - - // if (win) { - // recorder.start({ - // onAudio: (audio: object, speech: boolean) => { - // if (win) { - // win.setTitle("Listening..."); - // // win.webContents.send('render-audio', { - // // audio: audio, - // // speech: speech - // // }) - // if (speech) { - // win.setTitle("Recording..."); - // // TODO: send audio to crimata BE - // // ws.send(audio); - // } - // } - // } - // }); - // } + + ws = new WebSocket("ws://localhost:8080"); + ws.on("open", function open() { + ws.send("hernandeze2@xavier.edu"); + }); + ws.on("message", (message: any) => { + const parsed = JSON.parse(message); + console.log('new message', message) + if (win) { + win.webContents.send('render-message', { + message: parsed + }) + } + }); + + ipcMain.on('send-message', (Event: any, payload: any) => { + const stringMessage = JSON.stringify(payload.message) + ws.send(stringMessage); + }) + + ipcMain.on('update-menu-bar', (Event: any, payload: any) => { + // win.setTitle("Listening..."); + }) }) win.on("closed", () => { win = null; + ws = null; }); } diff --git a/src/components/UI/UIDetails/messageRenderer.vue b/src/components/UI/UIDetails/messageRenderer.vue index 02a14e8..6084c17 100644 --- a/src/components/UI/UIDetails/messageRenderer.vue +++ b/src/components/UI/UIDetails/messageRenderer.vue @@ -12,7 +12,6 @@ class="messageList" transform="translate(0, 25)" preserverAspectRatio="none" - > \ No newline at end of file + }); + return { center }; + }, +}); + diff --git a/src/components/input/inputDetails/textInput.vue b/src/components/input/inputDetails/textInput.vue index 06419e9..c4e1f16 100644 --- a/src/components/input/inputDetails/textInput.vue +++ b/src/components/input/inputDetails/textInput.vue @@ -1,5 +1,11 @@