mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Rename socket manager to socket service
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { MessageContext, MessageHandler } from '@/operations/messages';
|
||||
import { LocalNodeDeleteMessageInput } from '@/operations/messages/local-node-delete';
|
||||
import { socketManager } from '@/main/sockets/socket-manager';
|
||||
import { socketService } from '@/main/services/socket-service';
|
||||
|
||||
export class LocalNodeDeleteMessageHandler
|
||||
implements MessageHandler<LocalNodeDeleteMessageInput>
|
||||
@@ -9,6 +9,6 @@ export class LocalNodeDeleteMessageHandler
|
||||
context: MessageContext,
|
||||
input: LocalNodeDeleteMessageInput
|
||||
): Promise<void> {
|
||||
socketManager.sendMessage(context.accountId, input);
|
||||
socketService.sendMessage(context.accountId, input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MessageContext, MessageHandler } from '@/operations/messages';
|
||||
import { LocalNodeSyncMessageInput } from '@/operations/messages/local-node-sync';
|
||||
import { socketManager } from '@/main/sockets/socket-manager';
|
||||
import { socketService } from '@/main/services/socket-service';
|
||||
|
||||
export class LocalNodeSyncMessageHandler
|
||||
implements MessageHandler<LocalNodeSyncMessageInput>
|
||||
@@ -9,6 +9,6 @@ export class LocalNodeSyncMessageHandler
|
||||
context: MessageContext,
|
||||
input: LocalNodeSyncMessageInput
|
||||
): Promise<void> {
|
||||
socketManager.sendMessage(context.accountId, input);
|
||||
socketService.sendMessage(context.accountId, input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MessageContext, MessageHandler } from '@/operations/messages';
|
||||
import { LocalUserNodeSyncMessageInput } from '@/operations/messages/local-user-node-sync';
|
||||
import { socketManager } from '@/main/sockets/socket-manager';
|
||||
import { socketService } from '@/main/services/socket-service';
|
||||
|
||||
export class LocalUserNodeSyncMessageHandler
|
||||
implements MessageHandler<LocalUserNodeSyncMessageInput>
|
||||
@@ -9,6 +9,6 @@ export class LocalUserNodeSyncMessageHandler
|
||||
context: MessageContext,
|
||||
input: LocalUserNodeSyncMessageInput
|
||||
): Promise<void> {
|
||||
socketManager.sendMessage(context.accountId, input);
|
||||
socketService.sendMessage(context.accountId, input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { databaseService } from '@/main/data/database-service';
|
||||
import { socketManager } from '@/main/sockets/socket-manager';
|
||||
import { socketService } from '@/main/services/socket-service';
|
||||
import { MutationChange, MutationHandler, MutationResult } from '@/main/types';
|
||||
import { ServerNodeDeleteMutationInput } from '@/operations/mutations/server-node-delete';
|
||||
|
||||
@@ -45,7 +45,7 @@ export class ServerNodeDeleteMutationHandler
|
||||
userId: userId,
|
||||
});
|
||||
|
||||
socketManager.sendMessage(workspace.account_id, {
|
||||
socketService.sendMessage(workspace.account_id, {
|
||||
type: 'local_node_delete',
|
||||
nodeId: input.id,
|
||||
workspaceId: input.workspaceId,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { databaseService } from '@/main/data/database-service';
|
||||
import { socketManager } from '@/main/sockets/socket-manager';
|
||||
import { socketService } from '@/main/services/socket-service';
|
||||
import { hasInsertChanges, hasUpdateChanges } from '@/main/utils';
|
||||
import { MutationHandler, MutationResult } from '@/main/types';
|
||||
import { ServerNodeSyncMutationInput } from '@/operations/mutations/server-node-sync';
|
||||
@@ -64,7 +64,7 @@ export class ServerNodeSyncMutationHandler
|
||||
|
||||
const isInserted = hasInsertChanges(result);
|
||||
if (isInserted) {
|
||||
socketManager.sendMessage(workspace.account_id, {
|
||||
socketService.sendMessage(workspace.account_id, {
|
||||
type: 'local_node_sync',
|
||||
nodeId: input.id,
|
||||
userId: userId,
|
||||
@@ -110,7 +110,7 @@ export class ServerNodeSyncMutationHandler
|
||||
|
||||
const isUpdated = hasUpdateChanges(result);
|
||||
if (isUpdated) {
|
||||
socketManager.sendMessage(workspace.account_id, {
|
||||
socketService.sendMessage(workspace.account_id, {
|
||||
type: 'local_node_sync',
|
||||
nodeId: input.id,
|
||||
userId: userId,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { databaseService } from '@/main/data/database-service';
|
||||
import { socketManager } from '@/main/sockets/socket-manager';
|
||||
import { socketService } from '@/main/services/socket-service';
|
||||
import { MutationHandler, MutationResult } from '@/main/types';
|
||||
import { ServerUserNodeSyncMutationInput } from '@/operations/mutations/server-user-node-sync';
|
||||
|
||||
@@ -55,7 +55,7 @@ export class ServerUserNodeSyncMutationHandler
|
||||
)
|
||||
.execute();
|
||||
|
||||
socketManager.sendMessage(workspace.account_id, {
|
||||
socketService.sendMessage(workspace.account_id, {
|
||||
type: 'local_user_node_sync',
|
||||
userId: input.userId,
|
||||
nodeId: input.nodeId,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { join } from 'path';
|
||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils';
|
||||
import { eventBus } from '@/lib/event-bus';
|
||||
import { databaseService } from '@/main/data/database-service';
|
||||
import { socketManager } from '@/main/sockets/socket-manager';
|
||||
import { socketService } from '@/main/services/socket-service';
|
||||
import { synchronizer } from '@/main/synchronizer';
|
||||
import { avatarService } from '@/main/services/avatar-service';
|
||||
import { fileService } from '@/main/services/file-service';
|
||||
@@ -21,7 +21,7 @@ app.setName('Colanode');
|
||||
const createWindow = async (): Promise<void> => {
|
||||
await databaseService.init();
|
||||
assetService.checkAssets();
|
||||
socketManager.init();
|
||||
socketService.init();
|
||||
synchronizer.init();
|
||||
|
||||
// Create the browser window.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { SocketConnection } from '@/main/sockets/socket-connection';
|
||||
import { SocketConnection } from '@/main/services/socket-connection';
|
||||
import { databaseService } from '@/main/data/database-service';
|
||||
import { MessageInput } from '@/operations/messages';
|
||||
|
||||
const EVENT_LOOP_INTERVAL = 5000;
|
||||
|
||||
class SocketManager {
|
||||
class SocketService {
|
||||
private readonly accounts: Map<string, SocketConnection> = new Map();
|
||||
private initiated: boolean = false;
|
||||
|
||||
@@ -85,4 +85,4 @@ class SocketManager {
|
||||
}
|
||||
}
|
||||
|
||||
export const socketManager = new SocketManager();
|
||||
export const socketService = new SocketService();
|
||||
Reference in New Issue
Block a user