Compare commits
37 Commits
0.2.0
..
fb0ec66a14
| Author | SHA1 | Date | |
|---|---|---|---|
| fb0ec66a14 | |||
| 8457bdd4ca | |||
| fd8ac63dc3 | |||
| c4575fd219 | |||
| 8eb27ba8b9 | |||
| 7de4f3784b | |||
| 04df2250e9 | |||
| 99100a3086 | |||
| e3466bda30 | |||
| 550db1401b | |||
| 6a79be45bf | |||
| 82bf006f18 | |||
| 13edcb2f69 | |||
| 49d6aae1db | |||
| eadcd770ba | |||
| a3255602b3 | |||
| d471eef7af | |||
| 361ce1e817 | |||
| aa70083aed | |||
| 3b757d7ff7 | |||
| 19f3359106 | |||
| d676288315 | |||
| 671886781e | |||
| dc9a7b2e32 | |||
| 5951257c99 | |||
| a59e2a023b | |||
| 4f76bcc7c6 | |||
| 25b69fd7b6 | |||
| c18026bce6 | |||
| 91fa247696 | |||
| 97365371c8 | |||
| fdc0f1d73b | |||
| bc644c16e3 | |||
| 5497997455 | |||
| 53459648c6 | |||
| 8c97a726a7 | |||
| 2582f8e4d6 |
@@ -18,8 +18,3 @@
|
||||
* removed cache files ([7ee59c4](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/7ee59c434bf137a08fd560bbc02ceefbcfd90f04))
|
||||
* size of pieces and removed text view of the game state ([c60d00f](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/c60d00f9d25247504845654615065fbccd7fe448))
|
||||
* structure ([3e8c7c4](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/3e8c7c4057e55aeec7cee8c24f6751ff24912c93))
|
||||
## [0.0.0](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/compare/0.1.0...0.0.0) (2026-05-12)
|
||||
|
||||
### Features
|
||||
|
||||
* NCS-69 Challenge request ([#3](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/issues/3)) ([bad7366](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/bad7366bdbb048c20218257b30ac22efc9ecb6db))
|
||||
|
||||
@@ -263,6 +263,14 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (showChallengeDialog) {
|
||||
<div class="dialog-overlay" (click)="closeChallengeDialog()">
|
||||
<div class="dialog-card" (click)="$event.stopPropagation()">
|
||||
<app-challenge-create-dialog (closeChallengeDialog)="closeChallengeDialog()"></app-challenge-create-dialog>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (errorMessage) {
|
||||
<p class="error-banner">{{ errorMessage }}</p>
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
||||
showOptionsDialog = false;
|
||||
showJoinDialog = false;
|
||||
showImportDialog = false;
|
||||
showChallengeDialog = false;
|
||||
|
||||
gameIdInput = '';
|
||||
importMode: ImportMode = 'fen';
|
||||
@@ -223,11 +224,21 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
startOneVsOne(): void {
|
||||
if (!this.requireAuth(() => this.performStartOneVsOne())) {
|
||||
if (!this.requireAuth(() => this.openChallengeDialog())) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.performStartOneVsOne();
|
||||
this.openChallengeDialog();
|
||||
}
|
||||
|
||||
openChallengeDialog(): void {
|
||||
this.closeAllDialogs();
|
||||
this.showChallengeDialog = true;
|
||||
}
|
||||
|
||||
closeChallengeDialog(): void {
|
||||
this.showChallengeDialog = false;
|
||||
this.errorMessage = '';
|
||||
}
|
||||
|
||||
startVsBot(difficulty: Difficulty): void {
|
||||
@@ -352,28 +363,6 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
||||
action();
|
||||
}
|
||||
|
||||
private performStartOneVsOne(): void {
|
||||
if (this.creating) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.errorMessage = '';
|
||||
this.creating = true;
|
||||
|
||||
this.gameApi
|
||||
.createGame()
|
||||
.pipe(finalize(() => (this.creating = false)))
|
||||
.subscribe({
|
||||
next: (game) => {
|
||||
void this.router.navigate(['/game', game.gameId], {
|
||||
state: { theme: this.isSunsetMode ? 'light' : 'dark' }
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
this.errorMessage = getErrorMessage(error, 'Unable to create a game.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private performStartVsBot(difficulty: Difficulty): void {
|
||||
if (this.creating) {
|
||||
|
||||
@@ -3,11 +3,11 @@ import { HttpInterceptorFn } from '@angular/common/http';
|
||||
export const authInterceptor: HttpInterceptorFn = (req, next) => {
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
// Add token to protected endpoints only (not registration or login)
|
||||
const isProtectedEndpoint =
|
||||
req.url.includes('/api/account/me') ||
|
||||
req.url.includes('/api/account/bots') ||
|
||||
req.url.includes('/api/account/official-bots') ||
|
||||
req.url.includes('/api/board/game') ||
|
||||
req.url.includes('/api/challenge');
|
||||
|
||||
if (token && isProtectedEndpoint) {
|
||||
|
||||
@@ -10,6 +10,7 @@ export class GameStreamService {
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private streamSubscription: Subscription | null = null;
|
||||
private pollSubscription: Subscription | null = null;
|
||||
private lastGameStateHash: string | null = null;
|
||||
|
||||
startStreaming(
|
||||
gameId: string,
|
||||
@@ -20,7 +21,10 @@ export class GameStreamService {
|
||||
.streamGame(gameId)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: (event) => onEvent(event),
|
||||
next: (event) => {
|
||||
this.lastGameStateHash = JSON.stringify(event);
|
||||
onEvent(event);
|
||||
},
|
||||
error: () => {
|
||||
onStreamError();
|
||||
this.startPolling(gameId, onEvent);
|
||||
@@ -37,7 +41,7 @@ export class GameStreamService {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pollSubscription = interval(1500)
|
||||
this.pollSubscription = interval(5000)
|
||||
.pipe(
|
||||
startWith(0),
|
||||
switchMap(() => this.gameApi.getGame(gameId)),
|
||||
@@ -45,11 +49,16 @@ export class GameStreamService {
|
||||
)
|
||||
.subscribe({
|
||||
next: (game) => {
|
||||
const event: GameStreamEvent = {
|
||||
type: 'gameFull',
|
||||
game
|
||||
};
|
||||
onEvent(event);
|
||||
// Only emit if game state changed to avoid unnecessary updates
|
||||
const stateHash = JSON.stringify(game.state);
|
||||
if (this.lastGameStateHash !== stateHash) {
|
||||
this.lastGameStateHash = stateHash;
|
||||
const event: GameStreamEvent = {
|
||||
type: 'gameFull',
|
||||
game
|
||||
};
|
||||
onEvent(event);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -59,5 +68,6 @@ export class GameStreamService {
|
||||
this.pollSubscription?.unsubscribe();
|
||||
this.streamSubscription = null;
|
||||
this.pollSubscription = null;
|
||||
this.lastGameStateHash = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +84,19 @@ export class StreamHandlerService {
|
||||
}
|
||||
};
|
||||
|
||||
// Set timeout to fallback if WebSocket doesn't connect quickly
|
||||
const connectionTimeoutId = setTimeout(() => {
|
||||
if (!connected && !fallbackActive) {
|
||||
console.warn(`[StreamHandler] WebSocket timeout for ${gameId}, attempting NDJSON fallback`);
|
||||
ws.close();
|
||||
void startNdjsonFallback();
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
ws.onopen = () => {
|
||||
connected = true;
|
||||
clearTimeout(connectionTimeoutId);
|
||||
console.log(`[StreamHandler] WebSocket connected for ${gameId}`);
|
||||
};
|
||||
|
||||
ws.onmessage = (message) => {
|
||||
@@ -97,19 +108,23 @@ export class StreamHandlerService {
|
||||
};
|
||||
|
||||
ws.onerror = (error) => {
|
||||
console.warn(`[StreamHandler] WebSocket error for ${gameId}, attempting NDJSON fallback:`, error);
|
||||
if (!connected) {
|
||||
console.warn(`[StreamHandler] WebSocket error for ${gameId}:`, error);
|
||||
clearTimeout(connectionTimeoutId);
|
||||
if (!connected && !fallbackActive) {
|
||||
void startNdjsonFallback();
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
clearTimeout(connectionTimeoutId);
|
||||
console.warn(`[StreamHandler] WebSocket closed for ${gameId}, connected=${connected}`);
|
||||
if (!connected) {
|
||||
if (connected) {
|
||||
// Connection was established but closed, stream is complete
|
||||
observer.complete();
|
||||
} else if (!fallbackActive) {
|
||||
// Connection never established, try fallback
|
||||
console.log(`[StreamHandler] Starting NDJSON fallback for ${gameId}`);
|
||||
void startNdjsonFallback();
|
||||
} else {
|
||||
observer.complete();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
MAJOR=0
|
||||
MINOR=2
|
||||
MINOR=1
|
||||
PATCH=0
|
||||
|
||||
Reference in New Issue
Block a user