2022-11-19 15:36:29 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
2022-12-13 02:36:22 +00:00
|
|
|
import '../connection/ws_connection.dart';
|
|
|
|
|
2022-11-19 15:36:29 +00:00
|
|
|
class ConnectionCubit extends Cubit<ConnectionCubitState> {
|
|
|
|
static final ConnectionCubit _instance = ConnectionCubit._internal();
|
|
|
|
|
|
|
|
ConnectionCubit._internal() : super(ConnectionCubitState.init());
|
|
|
|
|
|
|
|
factory ConnectionCubit.getInstance() {
|
|
|
|
return ConnectionCubit();
|
|
|
|
}
|
|
|
|
|
|
|
|
factory ConnectionCubit() {
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
|
2023-05-28 12:54:46 +00:00
|
|
|
void connect() {
|
2022-12-13 02:36:22 +00:00
|
|
|
ServerConnection.getInstance().connect();
|
2022-11-19 15:36:29 +00:00
|
|
|
emit(ConnectionCubitState(true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ConnectionCubitState {
|
|
|
|
final bool reconnecting;
|
|
|
|
|
|
|
|
ConnectionCubitState(this.reconnecting);
|
|
|
|
|
|
|
|
factory ConnectionCubitState.init() {
|
|
|
|
return ConnectionCubitState(false);
|
|
|
|
}
|
|
|
|
}
|