# Flutter WebSocket STOMP Test

Nicht verbunden

## Flutter Dart Code Beispiel:

    import 'package:stomp_dart_client/stomp.dart';
    import 'package:stomp_dart_client/stomp_config.dart';
    import 'package:stomp_dart_client/stomp_frame.dart';
    import 'dart:convert';

    // RICHTIG: ws:// für WebSocket verwenden
    final stompClient = StompClient(
      config: StompConfig(
        url: 'ws://192.168.180.196:8080/websocket',  // ws:// NICHT http://
        onConnect: (StompFrame frame) {
          print('Connected to STOMP server');

          // Nachrichten abonnieren
          stompClient.subscribe(
            destination: '/topic/messages',
            callback: (StompFrame frame) {
              print('Received: ${frame.body}');
            },
          );
        },
        onWebSocketError: (dynamic error) => print('WebSocket Error: $error'),
        onStompError: (StompFrame frame) => print('Stomp Error: ${frame.body}'),
        onDisconnect: (StompFrame frame) => print('Disconnected'),
      ),
    );

    // Verbindung aktivieren
    stompClient.activate();

    // Nachricht senden
    void sendMessage(String content) {
      stompClient.send(
        destination: '/app/message',
        body: jsonEncode({
          'content': content,
          'sender': 'FlutterApp',
        }),
      );
    }

## Verfügbare Endpunkte:

- ws://192.168.180.196:8080/websocket - Native WebSocket (empfohlen für Flutter)
- ws://192.168.180.196:8080/stomp - Alternative WebSocket Endpunkt
- http://192.168.180.196:8080/ws - SockJS Endpunkt (nur für Browser)

## Häufiger Fehler:

FALSCH: `http://192.168.180.196:8080/websocket`

RICHTIG: `ws://192.168.180.196:8080/websocket`