Merge branch 'main' into feature-whiteboards-recent-and-history

# Conflicts:
#	front/src/App.vue
This commit is contained in:
Veljko Tosic
2026-02-16 18:20:35 +01:00
38 changed files with 989 additions and 13 deletions

View File

@@ -3,6 +3,7 @@ import {
HubConnectionBuilder,
HubConnectionState,
} from "@microsoft/signalr";
import {useAuthStore} from "@/stores/auth.ts";
export class SignalRService {
private connection: HubConnection;
@@ -10,8 +11,12 @@ export class SignalRService {
constructor(
hubUrl: string,
) {
const authStore = useAuthStore();
this.connection = new HubConnectionBuilder()
.withUrl(hubUrl)
.withUrl(hubUrl, {
accessTokenFactory: () => authStore.accessToken!
})
.withAutomaticReconnect()
.build();
}

View File

@@ -2,7 +2,7 @@ import {SignalRService} from "@/services/signalr.ts";
const client = new SignalRService(
`http://localhost:5039/testhub`,
`/hubs/test`,
);
export const testHubService = {

View File

@@ -0,0 +1,49 @@
import { SignalRService } from '@/services/signalr.ts'
import type { Rectangle, Whiteboard } from '@/types/whiteboard.ts'
const client = new SignalRService(`/hubs/whiteboard`)
export const whiteboardHubService = {
async connect() {
await client.start()
},
async disconnect() {
await client.stop()
},
async joinWhiteboard(id: string) {
await client.invoke('JoinWhiteboard', id)
},
async leaveWhiteboard(id: string) {
await client.invoke('LeaveWhiteboard', id)
},
async addRectangle(rectangle: Rectangle) {
await client.invoke('AddRectangle', rectangle)
},
onInitWhiteboard(callback: (whiteboard: Whiteboard) => void) {
client.on<Whiteboard>('InitWhiteboard', callback)
},
onAddedRectangle(callback: (rectangle: Rectangle) => void) {
client.on<Rectangle>('AddedRectangle', callback)
},
onJoined(callback: (userId: string) => void) {
client.on<string>('Joined', callback)
},
onLeaved(callback: (userId: string) => void) {
client.on<string>('Leaved', callback)
},
offAll() {
client.off('InitWhiteboard')
client.off('AddedRectangle')
client.off('Joined')
client.off('Leaved')
},
}