mirror of
https://github.com/appwrite/sdk-for-flutter.git
synced 2026-04-07 19:27:41 +00:00
websocket close notify
This commit is contained in:
+1
-2
@@ -1,7 +1,6 @@
|
||||
## 8.2.1
|
||||
|
||||
* Fix OAuth issue on web
|
||||
* Make improvements in helper classes
|
||||
* Fix: notify callback when websocket closes [#604](https://github.com/appwrite/sdk-generator/pull/604)
|
||||
|
||||
## 8.2.0
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://pub.dartlang.org/packages/appwrite)
|
||||

|
||||

|
||||

|
||||
[](https://travis-ci.com/appwrite/sdk-generator)
|
||||
[](https://twitter.com/appwrite)
|
||||
[](https://appwrite.io/discord)
|
||||
|
||||
+10
-8
@@ -140,18 +140,18 @@ class ClientIO extends ClientBase with ClientMixin {
|
||||
Future init() async {
|
||||
if(_initProgress) return;
|
||||
_initProgress = true;
|
||||
// if web skip cookie implementation and origin header as those are automatically handled by browsers
|
||||
final Directory cookieDir = await _getCookiePath();
|
||||
_cookieJar = PersistCookieJar(storage: FileStorage(cookieDir.path));
|
||||
_interceptors.add(CookieManager(_cookieJar));
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
addHeader('Origin',
|
||||
'appwrite-${Platform.operatingSystem}://${packageInfo.packageName}');
|
||||
|
||||
//creating custom user agent
|
||||
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
var device = '';
|
||||
try {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
addHeader('Origin',
|
||||
'appwrite-${Platform.operatingSystem}://${packageInfo.packageName}');
|
||||
|
||||
//creating custom user agent
|
||||
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
if (Platform.isAndroid) {
|
||||
final andinfo = await deviceInfoPlugin.androidInfo;
|
||||
device =
|
||||
@@ -174,12 +174,14 @@ class ClientIO extends ClientBase with ClientMixin {
|
||||
final macinfo = await deviceInfoPlugin.macOsInfo;
|
||||
device = '(Macintosh; ${macinfo.model})';
|
||||
}
|
||||
addHeader(
|
||||
'user-agent', '${packageInfo.packageName}/${packageInfo.version} $device');
|
||||
} catch (e) {
|
||||
debugPrint('Error getting device info: $e');
|
||||
device = Platform.operatingSystem;
|
||||
addHeader(
|
||||
'user-agent', '$device');
|
||||
}
|
||||
addHeader(
|
||||
'user-agent', '${packageInfo.packageName}/${packageInfo.version} $device');
|
||||
|
||||
_initialized = true;
|
||||
_initProgress = false;
|
||||
|
||||
@@ -23,7 +23,7 @@ class CookieManager extends Interceptor {
|
||||
}
|
||||
return request;
|
||||
}).catchError((e, stackTrace) {
|
||||
// throw AppwriteException(e.message);
|
||||
return request;
|
||||
});
|
||||
return request;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class CookieManager extends Interceptor {
|
||||
@override
|
||||
FutureOr<http.Response> onResponse(http.Response response) {
|
||||
_saveCookies(response).then((_) => response).catchError((e, stackTrace) {
|
||||
// throw AppwriteException(e.message);
|
||||
return response;
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class Locale implements Model {
|
||||
final String continentCode;
|
||||
/// Continent name. This field support localization.
|
||||
final String continent;
|
||||
/// True if country is part of the Europian Union.
|
||||
/// True if country is part of the European Union.
|
||||
final bool eu;
|
||||
/// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format
|
||||
final String currency;
|
||||
|
||||
@@ -76,6 +76,24 @@ mixin RealtimeMixin {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, onDone: () {
|
||||
for (var list in _channels.values) {
|
||||
for (var stream in list) {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
_channels.clear();
|
||||
_closeConnection();
|
||||
}, onError: (err, stack) {
|
||||
for (var list in _channels.values) {
|
||||
for (var stream in list) {
|
||||
stream.sink.addError(err, stack);
|
||||
}
|
||||
}
|
||||
if (_websok?.closeCode != null && _websok?.closeCode != 1008) {
|
||||
debugPrint("Reconnecting in one second.");
|
||||
Future.delayed(Duration(seconds: 1), _createSocket);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
if (e is AppwriteException) {
|
||||
|
||||
+2
-1
@@ -16,11 +16,12 @@ dependencies:
|
||||
flutter_web_auth_2: ^2.0.2
|
||||
http: ^0.13.5
|
||||
package_info_plus: ^3.0.2
|
||||
path_provider: ^2.0.11
|
||||
path_provider: ^2.0.12
|
||||
web_socket_channel: ^2.2.0
|
||||
universal_html: ^2.0.8
|
||||
|
||||
dev_dependencies:
|
||||
path_provider_platform_interface: ^2.0.5
|
||||
flutter_lints: ^2.0.1
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user