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">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$/FencerJudgeBack" />
|
<file type="web" url="file://$PROJECT_DIR$/FencerJudgeBack" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager">
|
<component name="ProjectRootManager" version="2" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -48,11 +48,6 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center mt-3">
|
<div class="text-center mt-3">
|
||||||
<span>© FencerJudge - Tous droits réservés </span>
|
<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>
|
||||||
<div class="flag-bar" title="France"></div>
|
<div class="flag-bar" title="France"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,81 +1,70 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, Subject, BehaviorSubject } from 'rxjs';
|
||||||
import { Matches, MatchState } from '@interfaces/matches';
|
import { Matches } from '@interfaces/matches';
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class MatchesService {
|
export class MatchesService {
|
||||||
private matches: Matches[] = [
|
private socket?: WebSocket;
|
||||||
{
|
private matchUpdates$ = new Subject<Matches[]>();
|
||||||
id: 1,
|
private allMatches: Matches[] = [];
|
||||||
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,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
constructor() {
|
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[]> {
|
getMatches(): Observable<Matches[]> {
|
||||||
console.log('[MatchesService] Fetching all matches');
|
return this.matchUpdates$.asObservable();
|
||||||
return of(this.matches);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchById(id: number): Observable<Matches | undefined> {
|
getMatchById(id: number): Observable<Matches | undefined> {
|
||||||
const match = this.matches.find((m) => m.id === id);
|
const match = this.allMatches.find((m) => m.id === id);
|
||||||
console.log(`[MatchesService] Fetching match ID: ${id}`, match);
|
console.log(`[MatchesService] Match ID ${id} récupéré :`, match);
|
||||||
return of(match);
|
return new BehaviorSubject(match).asObservable();
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMatch(id: number, updatedData: Partial<Matches>): void {
|
updateMatch(id: number, updatedData: Partial<Matches>): void {
|
||||||
const match = this.matches.find((m) => m.id === id);
|
const matchIndex = this.allMatches.findIndex((m) => m.id === id);
|
||||||
if (match) {
|
if (matchIndex !== -1) {
|
||||||
Object.assign(match, updatedData);
|
const updatedMatch = { ...this.allMatches[matchIndex], ...updatedData };
|
||||||
console.log(`[MatchesService] Match ${id} mis à jour :`, match);
|
this.allMatches[matchIndex] = updatedMatch;
|
||||||
|
this.matchUpdates$.next([...this.allMatches]); // émettre un nouveau tableau
|
||||||
|
console.log(
|
||||||
|
`[MatchesService] Match ${id} mis à jour localement :`,
|
||||||
|
updatedMatch
|
||||||
|
);
|
||||||
} else {
|
} 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 />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.9.25" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
Loading…
Add table
Reference in a new issue