Test failed websocket
This commit is contained in:
parent
d8b7aee6c7
commit
2ce7bde884
8 changed files with 83 additions and 68 deletions
15
.idea/gradle.xml
generated
Normal file
15
.idea/gradle.xml
generated
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/FencerJudgeBack" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/FencerJudgeBack" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/kotlinc.xml
generated
Normal file
9
.idea/kotlinc.xml
generated
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Kotlin2JvmCompilerArguments">
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
</component>
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.9.25" />
|
||||
</component>
|
||||
</project>
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
|
@ -4,7 +4,7 @@
|
|||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$/FencerJudgeBack" />
|
||||
</component>
|
||||
<component name="ProjectRootManager">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -48,11 +48,6 @@
|
|||
</div>
|
||||
<div class="text-center mt-3">
|
||||
<span>© FencerJudge - Tous droits réservés </span>
|
||||
<a href="#" class="text-white me-3 SpaceMargin-02">Mentions légales</a>
|
||||
<a href="#" class="text-white me-3">Cookies</a>
|
||||
<a href="#" class="text-white me-3">Accessibilité</a>
|
||||
<a routerLink="/contact" class="text-white me-3">Nous contacter</a>
|
||||
<a routerLink="/blogs" class="text-white me-3">Presse</a>
|
||||
</div>
|
||||
<div class="flag-bar" title="France"></div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,81 +1,70 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { Matches, MatchState } from '@interfaces/matches';
|
||||
import { Observable, Subject, BehaviorSubject } from 'rxjs';
|
||||
import { Matches } from '@interfaces/matches';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class MatchesService {
|
||||
private matches: Matches[] = [
|
||||
{
|
||||
id: 1,
|
||||
refereeID: 10,
|
||||
player1ID: 1,
|
||||
score1: 15,
|
||||
player2ID: 2,
|
||||
score2: 13,
|
||||
country: 'France',
|
||||
city: 'Paris',
|
||||
weapon: 'Fleuret',
|
||||
date: new Date('2025-06-10T14:00:00'),
|
||||
state: MatchState.OVER,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
refereeID: 11,
|
||||
player1ID: 3,
|
||||
score1: 5,
|
||||
player2ID: 4,
|
||||
score2: 7,
|
||||
country: 'France',
|
||||
city: 'Lyon',
|
||||
weapon: 'Épée',
|
||||
date: new Date('2025-06-15T10:00:00'),
|
||||
state: MatchState.ONGOING,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
refereeID: 12,
|
||||
player1ID: 5,
|
||||
score1: 0,
|
||||
player2ID: 6,
|
||||
score2: 0,
|
||||
country: 'Belgique',
|
||||
city: 'Bruxelles',
|
||||
weapon: 'Sabre',
|
||||
date: new Date('2025-06-20T16:30:00'),
|
||||
state: MatchState.NOT_STARTED,
|
||||
},
|
||||
];
|
||||
private socket?: WebSocket;
|
||||
private matchUpdates$ = new Subject<Matches[]>();
|
||||
private allMatches: Matches[] = [];
|
||||
|
||||
constructor() {
|
||||
console.log('[MatchesService] Initial matches loaded:', this.matches);
|
||||
this.connectToMatchUpdatesWebSocket();
|
||||
}
|
||||
|
||||
private connectToMatchUpdatesWebSocket(): void {
|
||||
const wsUrl = 'ws://localhost:8080/ws/matches';
|
||||
this.socket = new WebSocket(wsUrl);
|
||||
|
||||
this.socket.onopen = () => {
|
||||
console.log('[WebSocket] ✅ Connecté à', wsUrl);
|
||||
};
|
||||
|
||||
this.socket.onmessage = (event) => {
|
||||
try {
|
||||
const data = JSON.parse(event.data) as Matches[];
|
||||
console.log('[WebSocket] 📥 Données reçues :', data);
|
||||
this.matchUpdates$.next(data);
|
||||
} catch (e) {
|
||||
console.error('[WebSocket] ❌ Erreur de parsing JSON', e);
|
||||
}
|
||||
};
|
||||
|
||||
this.socket.onerror = (err) => {
|
||||
console.error('[WebSocket] ❌ Erreur :', err);
|
||||
};
|
||||
|
||||
this.socket.onclose = () => {
|
||||
console.warn('[WebSocket] 🔌 Fermeture de la connexion');
|
||||
};
|
||||
}
|
||||
|
||||
getMatches(): Observable<Matches[]> {
|
||||
console.log('[MatchesService] Fetching all matches');
|
||||
return of(this.matches);
|
||||
return this.matchUpdates$.asObservable();
|
||||
}
|
||||
|
||||
getMatchById(id: number): Observable<Matches | undefined> {
|
||||
const match = this.matches.find((m) => m.id === id);
|
||||
console.log(`[MatchesService] Fetching match ID: ${id}`, match);
|
||||
return of(match);
|
||||
}
|
||||
|
||||
// Préparation future pour WebSocket
|
||||
connectToMatchUpdatesWebSocket(): void {
|
||||
console.log(
|
||||
'[MatchesService] WebSocket connection placeholder initialized'
|
||||
);
|
||||
// ici tu pourrais plus tard faire : this.socket = new WebSocket('ws://...') etc.
|
||||
const match = this.allMatches.find((m) => m.id === id);
|
||||
console.log(`[MatchesService] Match ID ${id} récupéré :`, match);
|
||||
return new BehaviorSubject(match).asObservable();
|
||||
}
|
||||
|
||||
updateMatch(id: number, updatedData: Partial<Matches>): void {
|
||||
const match = this.matches.find((m) => m.id === id);
|
||||
if (match) {
|
||||
Object.assign(match, updatedData);
|
||||
console.log(`[MatchesService] Match ${id} mis à jour :`, match);
|
||||
const matchIndex = this.allMatches.findIndex((m) => m.id === id);
|
||||
if (matchIndex !== -1) {
|
||||
const updatedMatch = { ...this.allMatches[matchIndex], ...updatedData };
|
||||
this.allMatches[matchIndex] = updatedMatch;
|
||||
this.matchUpdates$.next([...this.allMatches]); // émettre un nouveau tableau
|
||||
console.log(
|
||||
`[MatchesService] Match ${id} mis à jour localement :`,
|
||||
updatedMatch
|
||||
);
|
||||
} else {
|
||||
console.warn(`[MatchesService] Match ${id} introuvable`);
|
||||
console.warn(`[MatchesService] Match ${id} non trouvé pour mise à jour`);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.socket?.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
6
db.lock.db
Normal file
6
db.lock.db
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#FileLock
|
||||
#Mon Jun 02 17:12:33 CEST 2025
|
||||
hostName=ExostFlash
|
||||
id=197313393c88a931fa21bf5ce1281b7253870b00683
|
||||
method=file
|
||||
server=192.167.2.100\:54366
|
||||
BIN
db.mv.db
Normal file
BIN
db.mv.db
Normal file
Binary file not shown.
|
|
@ -4,5 +4,6 @@
|
|||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.9.25" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Loading…
Add table
Reference in a new issue