restart socket session on renderer logout
This commit is contained in:
parent
918b65f068
commit
61253f9cc2
6 changed files with 25 additions and 56 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -4,7 +4,7 @@ node_modules
|
|||
/crate/target/*
|
||||
/.log
|
||||
|
||||
rawAudio.wav
|
||||
crash.log
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
|
|
|
|||
49
crash.log
49
crash.log
|
|
@ -1,49 +0,0 @@
|
|||
PID 335844 received SIGSEGV for address: 0xc
|
||||
/home/enrique/Developer/electron-app/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x37a5)[0x7f1c071387a5]
|
||||
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f1c10ffa3c0]
|
||||
/home/enrique/Developer/electron-app/node_modules/electron/dist/electron dist_electron(+0x72d9550)[0x55ccd61fe550]
|
||||
PID 60257 received SIGSEGV for address: 0x7fa04ceffff0
|
||||
0 segfault-handler.node 0x00000001131c6e60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||
1 libsystem_platform.dylib 0x00007fff2063fd7d _sigtramp + 29
|
||||
2 libc++abi.dylib 0x00007fff205bf4ee _ZN10__cxxabiv112_GLOBAL__N_110construct_Ev + 0
|
||||
3 naudiodon.node 0x000000011318a8c1 _ZN10streampunk9PaContext12readPaBufferEPKvjd + 75
|
||||
4 naudiodon.node 0x000000011318a72e _ZN10streampunk10PaCallbackEPKvPvmPK24PaStreamCallbackTimeInfomS2_ + 98
|
||||
5 libportaudio.dylib 0x00000001131b1bdd AdaptingInputOnlyProcess + 765
|
||||
6 libportaudio.dylib 0x00000001131b0962 PaUtil_EndBufferProcessing + 514
|
||||
7 libportaudio.dylib 0x00000001131b6c74 AudioIOProc + 1988
|
||||
8 CoreAudio 0x0000000120d69e0f AUGenericOutputFactory + 8547
|
||||
9 CoreAudio 0x00007fff21f870bb ___ZN19HALC_ProxyIOContextC2Ejj_block_invoke + 6591
|
||||
PID 60239 received SIGSEGV for address: 0x7fa80def9000
|
||||
0 segfault-handler.node 0x0000000111cf2e60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||
1 libsystem_platform.dylib 0x00007fff2063fd7d _sigtramp + 29
|
||||
2 ??? 0x0000ffff00001fa0 0x0 + 281470681751456
|
||||
3 naudiodon.node 0x0000000111cb68c1 _ZN10streampunk9PaContext12readPaBufferEPKvjd + 75
|
||||
4 naudiodon.node 0x0000000111cb672e _ZN10streampunk10PaCallbackEPKvPvmPK24PaStreamCallbackTimeInfomS2_ + 98
|
||||
5 libportaudio.dylib 0x0000000111cddbdd AdaptingInputOnlyProcess + 765
|
||||
6 libportaudio.dylib 0x0000000111cdc962 PaUtil_EndBufferProcessing + 514
|
||||
7 libportaudio.dylib 0x0000000111ce2c74 AudioIOProc + 1988
|
||||
8 CoreAudio 0x0000000120fa7e0f AUGenericOutputFactory + 8547
|
||||
9 CoreAudio 0x00007fff21f870bb ___ZN19HALC_ProxyIOContextC2Ejj_block_invoke + 6591
|
||||
10 CoreAudio 0x00007fff22129f2a _ZN13HALB_IOThread5EntryEPv + 72
|
||||
11 libsystem_pthread.dylib 0x00007fff205fb950 _pthread_start + 224
|
||||
12 libsystem_pthread.dylib 0x00007fff205f747b thread_start + 15
|
||||
PID 60328 received SIGSEGV for address: 0x7f900fab4000
|
||||
0 segfault-handler.node 0x0000000116724e60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||
1 libsystem_platform.dylib 0x00007fff2063fd7d _sigtramp + 29
|
||||
2 libc++abi.dylib 0x00007fff205bf4ee _ZN10__cxxabiv112_GLOBAL__N_110construct_Ev + 0
|
||||
3 naudiodon.node 0x00000001166e88c1 _ZN10streampunk9PaContext12readPaBufferEPKvjd + 75
|
||||
4 naudiodon.node 0x00000001166e872e _ZN10streampunk10PaCallbackEPKvPvmPK24PaStreamCallbackTimeInfomS2_ + 98
|
||||
5 libportaudio.dylib 0x000000011670fbdd AdaptingInputOnlyProcess + 765
|
||||
6 libportaudio.dylib 0x000000011670e962 PaUtil_EndBufferProcessing + 514
|
||||
7 libportaudio.dylib 0x0000000116714c74 AudioIOProc + 1988
|
||||
8 CoreAudio 0x000000011e8aee0f AUGenericOutputFactory + 8547
|
||||
9 CoreAudio 0x00007fff21f870bb ___ZN19HALC_ProxyIOContextC2Ejj_block_invoke + 6591
|
||||
10 CoreAudio 0x00007fff22129f2a _ZN13HALB_IOThread5EntryEPv + 72
|
||||
11 libsystem_pthread.dylib 0x00007fff205fb950 _pthread_start + 224
|
||||
12 libsystem_pthread.dylib 0x00007fff205f747b thread_start + 15
|
||||
PID 65740 received SIGSEGV for address: 0x7fbddef00000
|
||||
0 segfault-handler.node 0x0000000116e6ae60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||
PID 65817 received SIGSEGV for address: 0x7fe23f39d000
|
||||
0 segfault-handler.node 0x0000000110840e60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||
PID 93442 received SIGSEGV for address: 0x7f91092e1000
|
||||
0 segfault-handler.node 0x0000000111beae60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||
|
|
@ -77,6 +77,11 @@ const onClientMessage = (_event, payload: ClientMessage): void => {
|
|||
socket.send(JSON.stringify(payload));
|
||||
}
|
||||
|
||||
const restart = () => {
|
||||
auth = false;
|
||||
initSession();
|
||||
}
|
||||
|
||||
// Run every time we want to connect to backend.
|
||||
export function initSession(): void {
|
||||
|
||||
|
|
@ -100,6 +105,10 @@ export function initSession(): void {
|
|||
ipcMain.removeAllListeners('client-message');
|
||||
ipcMain.on('client-message', onClientMessage);
|
||||
|
||||
// handle renderer logout event
|
||||
ipcMain.removeAllListeners('logout');
|
||||
ipcMain.on('logout', (_event, _payload: string) => restart());
|
||||
|
||||
// Connect to the backend.
|
||||
socket.on('open', () => {
|
||||
console.log('Connected to Crimata Servers.');
|
||||
|
|
@ -130,14 +139,15 @@ export function initSession(): void {
|
|||
|
||||
socket.on('close', () => {
|
||||
console.log('Connection droped! Restarting...');
|
||||
auth = false;
|
||||
initSession();
|
||||
restart();
|
||||
});
|
||||
|
||||
socket.on("message", onMessage);
|
||||
}
|
||||
|
||||
|
||||
export function sendAudio(content: string, uid: string): void {
|
||||
const m = clientMessage("", content, uid);
|
||||
socket.send(JSON.stringify(m));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ process.once("loaded", () => {
|
|||
ipcRenderer.send("client-message", message.content);
|
||||
}
|
||||
|
||||
if (message.endpoint === "logout") {
|
||||
ipcRenderer.send("logout", message.content);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ import { RenderMessage , Annotation } from "@/types/message/index";
|
|||
import MessageItem from "@/components/messageItem.vue";
|
||||
import InputItem from "@/components/inputItem/inputItem.vue";
|
||||
import useMitt from "@/modules/mitt";
|
||||
|
||||
import { useRouter } from "vue-router";
|
||||
import { useAuth } from "@/modules/auth";
|
||||
import { useIpc } from "@/modules/ipc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "Messenger",
|
||||
|
|
@ -49,6 +49,7 @@ export default defineComponent({
|
|||
|
||||
setup() {
|
||||
|
||||
const { post } = useIpc();
|
||||
const { logout } = useAuth();
|
||||
const router = useRouter();
|
||||
|
||||
|
|
@ -73,6 +74,7 @@ export default defineComponent({
|
|||
const onLogout = () => {
|
||||
logout();
|
||||
router.push({ name: "login" });
|
||||
post("logout", "")
|
||||
}
|
||||
|
||||
const { emitter } = useMitt();
|
||||
|
|
|
|||
|
|
@ -9,12 +9,14 @@ wss.on("connection", function connection(ws, req) {
|
|||
|
||||
console.log(message)
|
||||
if (message === 'no-token' || message === 'undefined') {
|
||||
ws.send('success');
|
||||
} else if (message instanceof Buffer) {
|
||||
ws.send('locked');
|
||||
} else if (message instanceof String || typeof message === "string") {
|
||||
// audio message
|
||||
|
||||
console.log('caught the token', message)
|
||||
ws.send('success');
|
||||
} else {
|
||||
const parsed = JSON.parse(message);
|
||||
console.log('parsed', parsed)
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue