You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class _FuncionariosPageState extends State {
final FuncionariosSSE _funcionariosSSE = FuncionariosSSE();
final Logger _logger = Logger('FuncionariosPage');
late StreamSubscription<List> _subscription;
List _funcionarios = [];
@OverRide
void initState() {
super.initState();
_logger.info('Iniciando a página de funcionários');
_subscription = _funcionariosSSE.funcionariosStream.listen((event) {
_logger.info('Dados recebidos na página: $event');
setState(() {
_funcionarios = event;
});
});
_logger.info('Iniciando a conexão SSE');
_funcionariosSSE.connectSSE(0);
}
Launching lib\main.dart on Chrome in debug mode... Waiting for connection from debug service on Chrome... This app is linked to the debug service: ws://127.0.0.1:59215/iv6W3yNu310=/ws Debug service listening on ws://127.0.0.1:59215/iv6W3yNu310=/ws Debug service listening on ws://127.0.0.1:59215/iv6W3yNu310=/ws INFO: 2024-05-26 16:09:35.597: Login efetuado com sucesso para o tipo = 0 com success = true INFO: 2024-05-26 16:09:35.597: Sucesso no login INFO: 2024-05-26 16:09:35.607: Iniciando a página de funcionários INFO: 2024-05-26 16:09:35.608: Iniciando a conexão SSE INFO: 2024-05-26 16:09:35.609: Starting SSE connection... [EventFlux] ℹ️ Connection Initiated
can anyone help me please ?
i tried use eventflux: ^2.0.1 and eventflux: ^2.0.2
same behaviour
The text was updated successfully, but these errors were encountered:
Hi i'm building a simple college project, and i get here on EventFlux, i liked the example and i'm trying to use it
Here what i'm doing
`import 'dart:async';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:projetointegradoriiiflutter/http/funcionarios.dart';
class FuncionariosPage extends StatefulWidget {
const FuncionariosPage({super.key});
@OverRide
_FuncionariosPageState createState() => _FuncionariosPageState();
}
class _FuncionariosPageState extends State {
final FuncionariosSSE _funcionariosSSE = FuncionariosSSE();
final Logger _logger = Logger('FuncionariosPage');
late StreamSubscription<List> _subscription;
List _funcionarios = [];
@OverRide
void initState() {
super.initState();
_logger.info('Iniciando a página de funcionários');
_subscription = _funcionariosSSE.funcionariosStream.listen((event) {
_logger.info('Dados recebidos na página: $event');
setState(() {
_funcionarios = event;
});
});
_logger.info('Iniciando a conexão SSE');
_funcionariosSSE.connectSSE(0);
}
@OverRide
void dispose() {
_subscription.cancel();
_funcionariosSSE.dispose();
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Teste'),
),
body: _funcionarios.isEmpty
? const Center(
child: CircularProgressIndicator(),
)
: ListView.builder(
itemCount: _funcionarios.length,
itemBuilder: (context, index) {
final funcionario = _funcionarios[index];
_logger.info('Renderizando funcionário: $funcionario');
return ListTile(
title: Text(funcionario.nome),
subtitle: Text(funcionario.email),
);
})
);
}
}
`
`import 'dart:async';
import 'dart:convert';
import 'package:eventflux/eventflux.dart';
import 'package:logging/logging.dart';
class FuncionariosSSE {
final Logger _logger = Logger('FuncionariosSSE');
final StreamController<List> _streamController = StreamController();
Stream<List> get funcionariosStream => _streamController.stream;
void connectSSE(int tipo) async {
_logger.info('Starting SSE connection...');
EventFlux.instance.connect(
EventFluxConnectionType.get,
'http://localhost:8080/funcionarios/0/realtime',
onSuccessCallback: (EventFluxResponse? response) {
_logger.info('Connected successfully');
response!.stream!.listen((event) {
_logger.info('Event received: $event');
try {
final List decodedList = jsonDecode(event.data);
final funcionarios = decodedList.map((json) => Funcionario.fromJson(json)).toList();
_streamController.add(funcionarios);
_logger.info('Data decoded successfully: $funcionarios');
} catch (e) {
_logger.severe('Error decoding data: $e');
}
});
},
onError: (error) {
_logger.severe('Connection error: $error');
},
autoReconnect: true,
reconnectConfig: ReconnectConfig(
mode: ReconnectMode.linear,
interval: Duration(seconds: 5),
maxAttempts: 5,
),
);
}
void dispose() {
_streamController.close();
}
}
class Funcionario {
final String cpf;
final String departamento;
final String email;
final String nome;
final int tipo;
Funcionario({
required this.cpf,
required this.departamento,
required this.email,
required this.nome,
required this.tipo,
});
factory Funcionario.fromJson(Map<String, dynamic> json) {
return Funcionario(
cpf: json['cpf'] ?? '',
departamento: json['departamento'] ?? '',
email: json['email'] ?? '',
nome: json['nome'] ?? '',
tipo: json['tipo'] ?? 1,
);
}
}
`
My SSE endpoint is returning my data normally
and my application LOGS Are
Launching lib\main.dart on Chrome in debug mode... Waiting for connection from debug service on Chrome... This app is linked to the debug service: ws://127.0.0.1:59215/iv6W3yNu310=/ws Debug service listening on ws://127.0.0.1:59215/iv6W3yNu310=/ws Debug service listening on ws://127.0.0.1:59215/iv6W3yNu310=/ws INFO: 2024-05-26 16:09:35.597: Login efetuado com sucesso para o tipo = 0 com success = true INFO: 2024-05-26 16:09:35.597: Sucesso no login INFO: 2024-05-26 16:09:35.607: Iniciando a página de funcionários INFO: 2024-05-26 16:09:35.608: Iniciando a conexão SSE INFO: 2024-05-26 16:09:35.609: Starting SSE connection... [EventFlux] ℹ️ Connection Initiated
can anyone help me please ?
i tried use eventflux: ^2.0.1 and eventflux: ^2.0.2
same behaviour
The text was updated successfully, but these errors were encountered: