-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: grnd-alt <[email protected]>
- Loading branch information
Showing
8 changed files
with
112 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import SaveStatus from './SaveStatus.vue' | ||
import VueWrapper from './VueWrapper' | ||
|
||
export default function(props:{saving: Boolean}) { | ||
return React.createElement(VueWrapper, { componentProps: props, component: SaveStatus }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<NcButton type="tertiary" v-on:click="onClick"> | ||
<template #icon> | ||
<NcSavingIndicatorIcon :saving="saving" /> | ||
</template> | ||
</NcButton> | ||
</template> | ||
|
||
<script> | ||
import { NcButton, NcSavingIndicatorIcon } from '@nextcloud/vue' | ||
export default { | ||
name: "SaveStatus", | ||
components: { | ||
NcButton, | ||
NcSavingIndicatorIcon, | ||
}, | ||
props: { | ||
saving: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
onClick: { | ||
type: Function | ||
} | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,13 @@ | |
import dotenv from 'dotenv' | ||
import express from 'express' | ||
import PrometheusDataManager from './PrometheusDataManager.js' | ||
import StorageManager from './StorageManager.js' | ||
|
||
dotenv.config() | ||
|
||
export default class AppManager { | ||
|
||
/** @param {StorageManager} storageManager*/ | ||
Check warning on line 15 in websocket_server/AppManager.js GitHub Actions / NPM lint
|
||
constructor(storageManager) { | ||
this.app = express() | ||
this.storageManager = storageManager | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,20 @@ | |
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { Server as SocketIO } from 'socket.io' | ||
import { Socket, Server as SocketIO } from 'socket.io' | ||
import prometheusMetrics from 'socket.io-prometheus' | ||
import jwt from 'jsonwebtoken' | ||
import dotenv from 'dotenv' | ||
import Utils from './Utils.js' | ||
import { createAdapter } from '@socket.io/redis-streams-adapter' | ||
import SocketDataManager from './SocketDataManager.js' | ||
import StorageManager from './StorageManager.js' | ||
|
||
dotenv.config() | ||
|
||
export default class SocketManager { | ||
|
||
/** @param {StorageManager} storageManager */ | ||
Check warning on line 21 in websocket_server/SocketManager.js GitHub Actions / NPM lint
Check warning on line 21 in websocket_server/SocketManager.js GitHub Actions / NPM lint
Check warning on line 21 in websocket_server/SocketManager.js GitHub Actions / NPM lint
|
||
constructor(server, roomDataManager, storageManager) { | ||
this.roomDataManager = roomDataManager | ||
this.storageManager = storageManager | ||
|
@@ -92,7 +94,7 @@ export default class SocketManager { | |
}, | ||
) | ||
next(new Error('Connection verified')) | ||
} catch (e) {} | ||
} catch (e) { } | ||
|
||
next(new Error('Authentication error')) | ||
} | ||
|
@@ -107,6 +109,7 @@ export default class SocketManager { | |
socket.on('server-volatile-broadcast', (roomID, encryptedData) => | ||
this.serverVolatileBroadcastHandler(socket, roomID, encryptedData), | ||
) | ||
socket.on('store-to-server', (roomID) => this.storeToServerHandler(roomID, socket)) | ||
socket.on('image-add', (roomID, id, data) => this.imageAddHandler(socket, roomID, id, data)) | ||
socket.on('image-remove', (roomID, id, data) => this.imageRemoveHandler(socket, roomID, id, data)) | ||
socket.on('image-get', (roomID, id, data) => this.imageGetHandler(socket, roomID, id, data)) | ||
|
@@ -117,6 +120,17 @@ export default class SocketManager { | |
socket.on('disconnect', () => this.handleDisconnect(socket)) | ||
} | ||
|
||
/** | ||
* @param {int} roomID | ||
* @param {Socket} socket | ||
*/ | ||
async storeToServerHandler(roomID, socket) { | ||
this.storageManager.saveRoomDataToServer(roomID).then(() => { | ||
socket.emit("room-data-saved", roomID) | ||
socket.broadcast.to(roomID).emit("room-data-saved", roomID) | ||
}) | ||
} | ||
|
||
async handleDisconnect(socket) { | ||
await this.socketDataManager.deleteSocketData(socket.id) | ||
socket.removeAllListeners() | ||
|
@@ -213,7 +227,9 @@ export default class SocketManager { | |
socketData.user.id, | ||
) | ||
} | ||
|
||
/** | ||
* @param {Socket} socket | ||
*/ | ||
async serverVolatileBroadcastHandler(socket, roomID, encryptedData) { | ||
const payload = JSON.parse( | ||
Utils.convertArrayBufferToString(encryptedData), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters