This commit is contained in:
ExostFlash 2025-06-02 20:28:40 +02:00
parent 2ce7bde884
commit 0b98719753
5 changed files with 67 additions and 9 deletions

1
.idea/gradle.xml generated
View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>

View file

@ -1,9 +1,17 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { MatchesService } from '@services/matches/matches.service';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
standalone: false, standalone: false,
templateUrl: './home.component.html', templateUrl: './home.component.html',
styleUrl: './home.component.css', styleUrl: './home.component.css',
}) })
export class HomeComponent {} export class HomeComponent {
constructor(private matchesService: MatchesService) {}
send(): void {
this.matchesService.sendCurrentMatches();
}
}

View file

@ -1,9 +1,50 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable, Subject, BehaviorSubject } from 'rxjs'; import { Observable, Subject, BehaviorSubject } from 'rxjs';
import { Matches } from '@interfaces/matches'; import { Matches, MatchState } from '@interfaces/matches';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class MatchesService { 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 socket?: WebSocket;
private matchUpdates$ = new Subject<Matches[]>(); private matchUpdates$ = new Subject<Matches[]>();
private allMatches: Matches[] = []; private allMatches: Matches[] = [];
@ -13,7 +54,7 @@ export class MatchesService {
} }
private connectToMatchUpdatesWebSocket(): void { private connectToMatchUpdatesWebSocket(): void {
const wsUrl = 'ws://localhost:8080/ws/matches'; const wsUrl = 'http://localhost:8080/ws/matches-app';
this.socket = new WebSocket(wsUrl); this.socket = new WebSocket(wsUrl);
this.socket.onopen = () => { this.socket.onopen = () => {
@ -39,6 +80,20 @@ export class MatchesService {
}; };
} }
private sendMatchesToWebSocket(): void {
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
const dataToSend = JSON.stringify(this.matches);
this.socket.send(dataToSend);
console.log('[WebSocket] 📤 Données envoyées :', dataToSend);
} else {
console.warn("[WebSocket] ⚠️ Le WebSocket n'est pas encore ouvert.");
}
}
public sendCurrentMatches(): void {
this.sendMatchesToWebSocket();
}
getMatches(): Observable<Matches[]> { getMatches(): Observable<Matches[]> {
return this.matchUpdates$.asObservable(); return this.matchUpdates$.asObservable();
} }

View file

@ -1,6 +0,0 @@
#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

Binary file not shown.