Chat Updates & Stability

merge-requests/69/head
Aamir Muhammad 3 years ago
parent eb7e5a4837
commit 68ebecf98a

@ -5,6 +5,7 @@ import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
import 'package:mohem_flutter_app/api/dashboard_api_client.dart';
import 'package:mohem_flutter_app/api/offers_and_discounts_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
@ -24,6 +25,7 @@ import 'package:mohem_flutter_app/models/generic_response_model.dart';
import 'package:mohem_flutter_app/models/itg/itg_response_model.dart';
import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart';
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
import 'package:signalr_netcore/signalr_client.dart';
/// Mix-in [DiagnosticableTreeMixin] to have access to [debugFillProperties] for the devtool
// ignore: prefer_mixin
@ -40,6 +42,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
//Chat
bool isChatCounterLoding = true;
bool isChatHubLoding = true;
int chatUConvCounter = 0;
//Misssing Swipe
@ -100,6 +103,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
leaveBalanceAccrual = null;
isChatCounterLoding = true;
isChatHubLoding = true;
chatUConvCounter = 0;
ticketBalance = 0;
@ -302,6 +306,16 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
}
Future<HubConnection> getHubConnection() async {
HubConnection hub;
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
hub = HubConnectionBuilder()
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp)
.withAutomaticReconnect(retryDelays: <int>[2000, 5000, 10000, 20000]).build();
isChatHubLoding = false;
return hub;
}
void notify() {
notifyListeners();
}

@ -56,31 +56,15 @@ class _DashboardScreenState extends State<DashboardScreen> {
data.getUserAutoLoginToken().whenComplete(() {
buildHubConnection();
});
_onRefresh();
});
}
Future<void> buildHubConnection() async {
logger.d("Connnnnn Statred");
HttpConnectionOptions httpOp = HttpConnectionOptions(
skipNegotiation: false,
logMessageContent: true,
);
hubConnection = HubConnectionBuilder()
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp)
.withAutomaticReconnect(retryDelays: <int>[2000, 5000, 10000, 20000]).build();
hubConnection.onclose(({Exception? error}) {
logger.d("Con Closedddddd");
});
hubConnection.onreconnecting(({Exception? error}) {});
hubConnection.onreconnected(({String? connectionId}) {});
if (hubConnection.state != HubConnectionState.Connected) {
await hubConnection.start();
}
void buildHubConnection() async {
logger.d("Connection In Progresssss");
hubConnection = await data.getHubConnection();
await hubConnection.start();
logger.d("Connection Done");
}
@override

Loading…
Cancel
Save