master
jack ning 3 years ago
parent 95c9c66142
commit 96f627500b

@ -3,12 +3,14 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 50; objectVersion = 51;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3D8CAEDC2823D9A400EBA5BE /* Info-Release.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3D8CAEDA2823D9A400EBA5BE /* Info-Release.plist */; };
3D8CAEDD2823D9A400EBA5BE /* Info-Profile.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3D8CAEDB2823D9A400EBA5BE /* Info-Profile.plist */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
@ -36,6 +38,8 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
1BE257D15466126E85068C73 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1BE257D15466126E85068C73 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3D8CAEDA2823D9A400EBA5BE /* Info-Release.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-Release.plist"; sourceTree = "<group>"; };
3D8CAEDB2823D9A400EBA5BE /* Info-Profile.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-Profile.plist"; sourceTree = "<group>"; };
76314B5AB6122B6FE14148CA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; }; 76314B5AB6122B6FE14148CA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@ -47,7 +51,7 @@
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 97C147021CF9000F007C117D /* Info-Debug.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-Debug.plist"; sourceTree = "<group>"; };
BA046583E3DEF9F4762795D2 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; }; BA046583E3DEF9F4762795D2 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -70,7 +74,6 @@
BA046583E3DEF9F4762795D2 /* Pods-Runner.release.xcconfig */, BA046583E3DEF9F4762795D2 /* Pods-Runner.release.xcconfig */,
01F8337D7CF1E25D0170423C /* Pods-Runner.profile.xcconfig */, 01F8337D7CF1E25D0170423C /* Pods-Runner.profile.xcconfig */,
); );
name = Pods;
path = Pods; path = Pods;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
@ -112,7 +115,9 @@
97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
97C147021CF9000F007C117D /* Info.plist */, 97C147021CF9000F007C117D /* Info-Debug.plist */,
3D8CAEDB2823D9A400EBA5BE /* Info-Profile.plist */,
3D8CAEDA2823D9A400EBA5BE /* Info-Release.plist */,
97C146F11CF9000F007C117D /* Supporting Files */, 97C146F11CF9000F007C117D /* Supporting Files */,
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
@ -199,8 +204,10 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3D8CAEDC2823D9A400EBA5BE /* Info-Release.plist in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
3D8CAEDD2823D9A400EBA5BE /* Info-Profile.plist in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -368,7 +375,7 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L5F47963M2; DEVELOPMENT_TEAM = L5F47963M2;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
@ -492,7 +499,7 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L5F47963M2; DEVELOPMENT_TEAM = L5F47963M2;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
@ -511,7 +518,7 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L5F47963M2; DEVELOPMENT_TEAM = L5F47963M2;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>zh_CN</string>
<key>CFBundleDisplayName</key>
<string>萝卜丝Demo</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>bytedesk_demo</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSAppleMusicUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取音乐</string>
<key>NSCalendarsUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取日历</string>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) 拍照并发送图片</string>
<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取联系人推荐好友</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用,如果您需要使用后台定位功能请选择“始终允许”。</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) 发送语音</string>
<key>NSMotionUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取运动健身</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) 发送图片</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) 发送图片</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取语音识别</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocalNetworkUsageDescription</key>
<string>Allow flutter to access localhost</string>
<key>NSBonjourServices</key>
<array>
<string>_dartobservatory._tcp</string>
</array>
</dict>
</plist>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>zh_CN</string>
<key>CFBundleDisplayName</key>
<string>萝卜丝Demo</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>bytedesk_demo</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true />
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true />
</dict>
<key>NSAppleMusicUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取音乐</string>
<key>NSCalendarsUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取日历</string>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) 拍照并发送图片</string>
<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取联系人推荐好友</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用,如果您需要使用后台定位功能请选择“始终允许”。</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) 发送语音</string>
<key>NSMotionUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取运动健身</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) 发送图片</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) 发送图片</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取语音识别</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false />
</dict>
</plist>

@ -30,9 +30,9 @@ void main() {
String _subDomain = "vip"; String _subDomain = "vip";
// //
BytedeskKefu.init(_appKey, _subDomain); BytedeskKefu.init(_appKey, _subDomain);
// 使: // 使usernamenickname使
// BytedeskKefu.initWithUsernameAndNicknameAndAvatar('myuniappusername', '我是美女', 'https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/girl.png', subDomain, appKey); // BytedeskKefu.initWithUsernameAndNicknameAndAvatar('myflutterusername', '我是美女', 'https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/girl.png', _appKey, _subDomain);
// BytedeskKefu.initWithUsername('myuniappusername',subDomain, appKey); // username // BytedeskKefu.initWithUsername('myflutterusername', _appKey, _subDomain); // username
// /使 initWithUsernameAndNicknameinitWithUsernameAndNicknameAndAvatar // /使 initWithUsernameAndNicknameinitWithUsernameAndNicknameAndAvatar
// bytedesk_kefu/bytedesk_kefu.dart // bytedesk_kefu/bytedesk_kefu.dart
} }
@ -228,7 +228,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
} else if (event.message.type == BytedeskConstants.MESSAGE_TYPE_FILE) { } else if (event.message.type == BytedeskConstants.MESSAGE_TYPE_FILE) {
print('文件消息:' + event.message.fileUrl!); print('文件消息:' + event.message.fileUrl!);
} else { } else {
print('其他类型消息'); print('其他类型消息:' + event.message.type!);
} }
}); });
// token // token

@ -204,10 +204,10 @@ class _ChatTypePageState extends State<ChatTypePage> {
title: const Text('H5网页会话'), title: const Text('H5网页会话'),
trailing: const Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
print('h5 chat'); // print('h5 chat');
// : ->->()-> URL // : ->->()-> URL
String url = String url =
"https://h1.kefux.cn/chat/h5/index.html?sub=vip&uid=201808221551193&wid=201807171659201&type=workGroup&aid=&hidenav=1&ph=ph"; "https://h2.kefux.cn/chat/h5/index.html?sub=vip&uid=201808221551193&wid=201807171659201&type=workGroup&aid=&hidenav=1&ph=ph";
String title = 'H5在线客服演示'; String title = 'H5在线客服演示';
BytedeskKefu.startH5Chat(context, url, title); BytedeskKefu.startH5Chat(context, url, title);
}, },

@ -46,7 +46,7 @@ dependencies:
# 请在ios/Podfile中添加use_frameworks! # 请在ios/Podfile中添加use_frameworks!
vibration: ^1.7.3 vibration: ^1.7.3
# 在线客服 https://pub.dev/packages/bytedesk_kefu # 在线客服 https://pub.dev/packages/bytedesk_kefu
bytedesk_kefu: ^1.2.4 bytedesk_kefu: ^1.2.5
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.

@ -1,5 +1,9 @@
# Upgrade Log # Upgrade Log
## 1.2.5
* optimize user experience
## 1.2.4 ## 1.2.4
* optimize user experience * optimize user experience

@ -34,6 +34,8 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3D8CAED62823D79D00EBA5BE /* Info-Release.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-Release.plist"; sourceTree = "<group>"; };
3D8CAED82823D86F00EBA5BE /* Info-Profile.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-Profile.plist"; sourceTree = "<group>"; };
483DAFF376EA336E70A1AF95 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; }; 483DAFF376EA336E70A1AF95 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
72FBC4611027C1F583CD56F7 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; }; 72FBC4611027C1F583CD56F7 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@ -46,7 +48,7 @@
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 97C147021CF9000F007C117D /* Info-Debug.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-Debug.plist"; sourceTree = "<group>"; };
ACD77D260F2F57A568414FB9 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ACD77D260F2F57A568414FB9 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DB686996A5E8B0AF86E5C84F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; }; DB686996A5E8B0AF86E5C84F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -119,7 +121,9 @@
97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
97C147021CF9000F007C117D /* Info.plist */, 97C147021CF9000F007C117D /* Info-Debug.plist */,
3D8CAED82823D86F00EBA5BE /* Info-Profile.plist */,
3D8CAED62823D79D00EBA5BE /* Info-Release.plist */,
97C146F11CF9000F007C117D /* Supporting Files */, 97C146F11CF9000F007C117D /* Supporting Files */,
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
@ -367,7 +371,7 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L5F47963M2; DEVELOPMENT_TEAM = L5F47963M2;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
@ -491,7 +495,7 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L5F47963M2; DEVELOPMENT_TEAM = L5F47963M2;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
@ -510,7 +514,7 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L5F47963M2; DEVELOPMENT_TEAM = L5F47963M2;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>萝卜丝Demo</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSAppleMusicUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取音乐</string>
<key>NSCalendarsUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取日历</string>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) 拍照并发送图片</string>
<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取联系人推荐好友</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用,如果您需要使用后台定位功能请选择“始终允许”。</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) 发送语音</string>
<key>NSMotionUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取运动健身</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) 发送图片</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) 发送图片</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取语音识别</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocalNetworkUsageDescription</key>
<string>allow flutter to access localhost network</string>
<key>NSBonjourServices</key>
<array>
<string>_dartobservatory._tcp</string>
</array>
</dict>
</plist>

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>萝卜丝Demo</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSAppleMusicUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取音乐</string>
<key>NSCalendarsUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取日历</string>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) 拍照并发送图片</string>
<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取联系人推荐好友</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用,如果您需要使用后台定位功能请选择“始终允许”。</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>地图功能需要您的定位服务,否则无法使用。</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) 发送语音</string>
<key>NSMotionUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取运动健身</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) 发送图片</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) 发送图片</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>$(PRODUCT_NAME) 需要读取语音识别</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>

@ -30,9 +30,9 @@ void main() {
String _subDomain = "vip"; String _subDomain = "vip";
// //
BytedeskKefu.init(_appKey, _subDomain); BytedeskKefu.init(_appKey, _subDomain);
// 使: // 使usernamenickname使
// BytedeskKefu.initWithUsernameAndNicknameAndAvatar('myuniappusername', '我是美女', 'https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/girl.png', subDomain, appKey); // BytedeskKefu.initWithUsernameAndNicknameAndAvatar('myflutterusername', '我是美女', 'https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/girl.png', _appKey, _subDomain);
// BytedeskKefu.initWithUsername('myuniappusername',subDomain, appKey); // username // BytedeskKefu.initWithUsername('myflutterusername', _appKey, _subDomain); // username
// /使 initWithUsernameAndNicknameinitWithUsernameAndNicknameAndAvatar // /使 initWithUsernameAndNicknameinitWithUsernameAndNicknameAndAvatar
// bytedesk_kefu/bytedesk_kefu.dart // bytedesk_kefu/bytedesk_kefu.dart
} }
@ -134,6 +134,12 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
})); }));
}, },
), ),
// ListTile(
// title: Text('退出登录'),
// onTap: () {
// BytedeskKefu.logout();
// },
// ),
ListTile( ListTile(
title: Text('技术支持: QQ-3群: 825257535'), title: Text('技术支持: QQ-3群: 825257535'),
) )
@ -227,7 +233,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
} else if (event.message.type == BytedeskConstants.MESSAGE_TYPE_FILE) { } else if (event.message.type == BytedeskConstants.MESSAGE_TYPE_FILE) {
print('文件消息:' + event.message.fileUrl!); print('文件消息:' + event.message.fileUrl!);
} else { } else {
print('其他类型消息'); print('其他类型消息:' + event.message.type!);
} }
}); });
// token // token

@ -207,7 +207,7 @@ class _ChatTypePageState extends State<ChatTypePage> {
print('h5 chat'); print('h5 chat');
// : ->->()-> URL // : ->->()-> URL
String url = String url =
"https://h1.kefux.cn/chat/h5/index.html?sub=vip&uid=201808221551193&wid=201807171659201&type=workGroup&aid=&hidenav=1&ph=ph"; "https://h2.kefux.cn/chat/h5/index.html?sub=vip&uid=201808221551193&wid=201807171659201&type=workGroup&aid=&hidenav=1&ph=ph";
String title = 'H5在线客服演示'; String title = 'H5在线客服演示';
BytedeskKefu.startH5Chat(context, url, title); BytedeskKefu.startH5Chat(context, url, title);
}, },

@ -1,4 +1,4 @@
import 'dart:async'; // import 'dart:async';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/blocs/contact_bloc/bloc.dart'; import 'package:bytedesk_kefu/blocs/contact_bloc/bloc.dart';
import 'package:bytedesk_kefu/repositories/contact_repository.dart'; import 'package:bytedesk_kefu/repositories/contact_repository.dart';
@ -6,31 +6,29 @@ import 'package:bytedesk_kefu/repositories/contact_repository.dart';
class ContactBloc extends Bloc<ContactEvent, ContactState> { class ContactBloc extends Bloc<ContactEvent, ContactState> {
final ContactRepository contactRepository = new ContactRepository(); final ContactRepository contactRepository = new ContactRepository();
// ContactBloc({@required this.contactRepository}); ContactBloc() : super(ContactUninitialized()) {
ContactBloc() : super(ContactUninitialized()); on<RefreshContactEvent>(_mapRefreshContactToState);
}
// @override // @override
// ContactState get initialState => ContactUninitialized(); // Stream<ContactState> mapEventToState(ContactEvent event) async* {
// //
@override // if (event is RefreshContactEvent) {
Stream<ContactState> mapEventToState(ContactEvent event) async* { // yield* _mapRefreshContactToState(event);
// // } else {
if (event is RefreshContactEvent) { // //
yield* _mapRefreshContactToState(event); // }
} else { // }
//
}
}
Stream<ContactState> _mapRefreshContactToState( void _mapRefreshContactToState(
RefreshContactEvent event) async* { RefreshContactEvent event, Emitter<ContactState> emit) async {
yield ContactLoading(); emit(ContactLoading());
try { try {
// final List<Contact> contactList = await contactRepository.getContacts(); // final List<Contact> contactList = await contactRepository.getContacts();
// yield ContactLoadSuccess(contactList); // yield ContactLoadSuccess(contactList);
} catch (error) { } catch (error) {
print(error); print(error);
yield ContactLoadError(); emit(ContactLoadError());
} }
} }
} }

@ -1,4 +1,4 @@
import 'dart:async'; // import 'dart:async';
import 'package:bytedesk_kefu/blocs/feedback_bloc/bloc.dart'; import 'package:bytedesk_kefu/blocs/feedback_bloc/bloc.dart';
import 'package:bytedesk_kefu/model/helpCategory.dart'; import 'package:bytedesk_kefu/model/helpCategory.dart';
// import 'package:bytedesk_kefu/model/jsonResult.dart'; // import 'package:bytedesk_kefu/model/jsonResult.dart';
@ -9,55 +9,58 @@ class FeedbackBloc extends Bloc<FeedbackEvent, FeedbackState> {
// //
final FeedbackRepository feedbackRepository = new FeedbackRepository(); final FeedbackRepository feedbackRepository = new FeedbackRepository();
FeedbackBloc() : super(new UnFeedbackState()); FeedbackBloc() : super(new UnFeedbackState()) {
on<GetFeedbackCategoryEvent>(_mapGetFeedbackCategoryToState);
@override on<SubmitFeedbackEvent>(_mapSubmitFeedbackToState);
Stream<FeedbackState> mapEventToState( on<UploadImageEvent>(_mapUploadImageToState);
FeedbackEvent event,
) async* {
if (event is GetFeedbackCategoryEvent) {
yield* _mapGetFeedbackCategoryToState(event);
} else if (event is SubmitFeedbackEvent) {
yield* _mapSubmitFeedbackToState(event);
} else if (event is UploadImageEvent) {
yield* _mapUploadImageToState(event);
}
} }
Stream<FeedbackState> _mapGetFeedbackCategoryToState( // @override
GetFeedbackCategoryEvent event) async* { // void mapEventToState(
yield FeedbackLoading(); // FeedbackEvent event,
// ) async {
// if (event is GetFeedbackCategoryEvent) {
// yield* _mapGetFeedbackCategoryToState(event);
// } else if (event is SubmitFeedbackEvent) {
// yield* _mapSubmitFeedbackToState(event);
// } else if (event is UploadImageEvent) {
// yield* _mapUploadImageToState(event);
// }
// }
void _mapGetFeedbackCategoryToState(
GetFeedbackCategoryEvent event, Emitter<FeedbackState> emit) async {
emit(FeedbackLoading());
try { try {
final List<HelpCategory> categoryList = final List<HelpCategory> categoryList =
await feedbackRepository.getHelpFeedbackCategories(event.uid); await feedbackRepository.getHelpFeedbackCategories(event.uid);
yield FeedbackCategoryState(categoryList); emit(FeedbackCategoryState(categoryList));
} catch (error) { } catch (error) {
print(error); print(error);
yield FeedbackLoadError(); emit(FeedbackLoadError());
} }
} }
Stream<FeedbackState> _mapSubmitFeedbackToState( void _mapSubmitFeedbackToState(
SubmitFeedbackEvent event) async* { SubmitFeedbackEvent event, Emitter<FeedbackState> emit) async {
yield FeedbackSubmiting(); emit(FeedbackSubmiting());
try { try {
// final JsonResult jsonResult =
await feedbackRepository.submitFeedback(event.content, event.imageUrls); await feedbackRepository.submitFeedback(event.content, event.imageUrls);
yield FeedbackSubmitSuccess(); emit(FeedbackSubmitSuccess());
} catch (error) { } catch (error) {
print(error); print(error);
yield FeedbackSubmitError(); emit(FeedbackSubmitError());
} }
} }
Stream<FeedbackState> _mapUploadImageToState(UploadImageEvent event) async* { void _mapUploadImageToState(UploadImageEvent event, Emitter<FeedbackState> emit) async {
yield ImageUploading(); emit(ImageUploading());
try { try {
final String url = await feedbackRepository.upload(event.filePath); final String url = await feedbackRepository.upload(event.filePath);
yield UploadImageSuccess(url); emit(UploadImageSuccess(url));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
} }

@ -1,5 +1,4 @@
import 'dart:async'; // import 'dart:async';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/blocs/friend_bloc/bloc.dart'; import 'package:bytedesk_kefu/blocs/friend_bloc/bloc.dart';
import 'package:bytedesk_kefu/model/friend.dart'; import 'package:bytedesk_kefu/model/friend.dart';
@ -8,84 +7,90 @@ import 'package:bytedesk_kefu/repositories/friend_repository.dart';
class FriendBloc extends Bloc<FriendEvent, FriendState> { class FriendBloc extends Bloc<FriendEvent, FriendState> {
final FriendRepository friendRepository = new FriendRepository(); final FriendRepository friendRepository = new FriendRepository();
FriendBloc() : super(UnFriendState()); FriendBloc() : super(UnFriendState()) {
on<QueryFriendEvent>(_mapQueryFriendToState);
@override on<QueryFriendAddressEvent>(_mapQueryFriendAddressToState);
Stream<FriendState> mapEventToState(FriendEvent event) async* { on<UploadFriendAddressEvent>(_mapUploadFriendAddressToState);
// on<QueryFriendNearbyEvent>(_mapQueryFriendNearbyToState);
if (event is QueryFriendEvent) { on<UpdateFriendNearbyEvent>(_mapUpdateFriendNearbyToState);
yield* _mapQueryFriendToState(event);
} else if (event is UploadFriendAddressEvent) {
yield* _mapUploadFriendAddressToState(event);
} else if (event is QueryFriendAddressEvent) {
yield* _mapQueryFriendAddressToState(event);
} else if (event is QueryFriendNearbyEvent) {
yield* _mapQueryFriendNearbyToState(event);
} else if (event is UpdateFriendNearbyEvent) {
yield* _mapUpdateFriendNearbyToState(event);
}
} }
Stream<FriendState> _mapQueryFriendToState(QueryFriendEvent event) async* { // @override
yield FriendLoading(); // void mapEventToState(FriendEvent event) async {
// //
// if (event is QueryFriendEvent) {
// yield* _mapQueryFriendToState(event);
// } else if (event is UploadFriendAddressEvent) {
// yield* _mapUploadFriendAddressToState(event);
// } else if (event is QueryFriendAddressEvent) {
// yield* _mapQueryFriendAddressToState(event);
// } else if (event is QueryFriendNearbyEvent) {
// yield* _mapQueryFriendNearbyToState(event);
// } else if (event is UpdateFriendNearbyEvent) {
// yield* _mapUpdateFriendNearbyToState(event);
// }
// }
void _mapQueryFriendToState(QueryFriendEvent event, Emitter<FriendState> emit) async {
emit(FriendLoading());
try { try {
final List<Friend> friendList = final List<Friend> friendList =
await friendRepository.getFriends(event.page, event.size); await friendRepository.getFriends(event.page, event.size);
yield FriendLoadSuccess(friendList); emit(FriendLoadSuccess(friendList));
} catch (error) { } catch (error) {
print(error); print(error);
yield ErrorFriendState('friend error'); emit(ErrorFriendState('friend error'));
} }
} }
Stream<FriendState> _mapQueryFriendAddressToState( void _mapQueryFriendAddressToState(
QueryFriendAddressEvent event) async* { QueryFriendAddressEvent event, Emitter<FriendState> emit) async {
yield FriendLoading(); emit(FriendLoading());
try { try {
final List<Friend> friendList = final List<Friend> friendList =
await friendRepository.getFriendsAddress(event.page, event.size); await friendRepository.getFriendsAddress(event.page, event.size);
yield FriendLoadSuccess(friendList); emit(FriendLoadSuccess(friendList));
} catch (error) { } catch (error) {
print(error); print(error);
yield ErrorFriendState('friend error'); emit(ErrorFriendState('friend error'));
} }
} }
Stream<FriendState> _mapUploadFriendAddressToState( void _mapUploadFriendAddressToState(
UploadFriendAddressEvent event) async* { UploadFriendAddressEvent event, Emitter<FriendState> emit) async {
yield FriendLoading(); emit(FriendLoading());
try { try {
final Friend friend = final Friend friend =
await friendRepository.uploadAddress(event.nickname, event.mobile); await friendRepository.uploadAddress(event.nickname, event.mobile);
yield FriendCreateSuccess(friend: friend); emit(FriendCreateSuccess(friend: friend));
} catch (error) { } catch (error) {
print(error); print(error);
yield ErrorFriendState('friend error'); emit(ErrorFriendState('friend error'));
} }
} }
Stream<FriendState> _mapQueryFriendNearbyToState( void _mapQueryFriendNearbyToState(
QueryFriendNearbyEvent event) async* { QueryFriendNearbyEvent event, Emitter<FriendState> emit) async {
yield FriendLoading(); emit(FriendLoading());
try { try {
final List<Friend> friendList = final List<Friend> friendList =
await friendRepository.getFriendsNearby(event.page, event.size); await friendRepository.getFriendsNearby(event.page, event.size);
yield FriendLoadSuccess(friendList); emit(FriendLoadSuccess(friendList));
} catch (error) { } catch (error) {
print(error); print(error);
yield ErrorFriendState('friend error'); emit(ErrorFriendState('friend error'));
} }
} }
Stream<FriendState> _mapUpdateFriendNearbyToState( void _mapUpdateFriendNearbyToState(
UpdateFriendNearbyEvent event) async* { UpdateFriendNearbyEvent event, Emitter<FriendState> emit) async {
yield FriendLoading(); emit(FriendLoading());
try { try {
await friendRepository.updateLocation(event.latitude, event.longtitude); await friendRepository.updateLocation(event.latitude, event.longtitude);
yield FriendUpdateSuccess(); emit(FriendUpdateSuccess());
} catch (error) { } catch (error) {
print(error); print(error);
yield ErrorFriendState('friend error'); emit(ErrorFriendState('friend error'));
} }
} }
} }

@ -1,14 +1,17 @@
import 'dart:async'; // import 'dart:async';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import './bloc.dart'; import './bloc.dart';
class GroupBloc extends Bloc<GroupEvent, GroupState> { class GroupBloc extends Bloc<GroupEvent, GroupState> {
GroupBloc() : super(InitialGroupState());
@override GroupBloc() : super(InitialGroupState()) {
Stream<GroupState> mapEventToState(
GroupEvent event,
) async* {
// TODO: Add Logic
} }
// @override
// Stream<GroupState> mapEventToState(
// GroupEvent event,
// ) async* {
// // TODO: Add Logic
// }
} }

@ -9,39 +9,43 @@ class HelpBloc extends Bloc<HelpEvent, HelpState> {
// //
final HelpRepository helpRepository = new HelpRepository(); final HelpRepository helpRepository = new HelpRepository();
HelpBloc() : super(new UnHelpState()); HelpBloc() : super(new UnHelpState()) {
on<GetHelpCategoryEvent>(_mapGetHelpCategoryToState);
@override on<GetHelpArticleEvent>(_mapGetHelpArticleState);
Stream<HelpState> mapEventToState(HelpEvent event) async* {
if (event is GetHelpCategoryEvent) {
yield* _mapGetHelpCategoryToState(event);
} else if (event is GetHelpArticleEvent) {
yield* _mapGetHelpArticleState(event);
}
} }
Stream<HelpState> _mapGetHelpCategoryToState( // @override
GetHelpCategoryEvent event) async* { // Stream<HelpState> mapEventToState(HelpEvent event) async* {
yield HelpLoading(); // if (event is GetHelpCategoryEvent) {
// yield* _mapGetHelpCategoryToState(event);
// } else if (event is GetHelpArticleEvent) {
// yield* _mapGetHelpArticleState(event);
// }
// }
void _mapGetHelpCategoryToState(
GetHelpCategoryEvent event, Emitter<HelpState> emit) async {
emit(HelpLoading());
try { try {
final List<HelpCategory> categoryList = final List<HelpCategory> categoryList =
await helpRepository.getHelpCategories(event.uid); await helpRepository.getHelpCategories(event.uid);
yield HelpCategoryState(categoryList); emit(HelpCategoryState(categoryList));
} catch (error) { } catch (error) {
print(error); print(error);
yield HelpLoadError(); emit(HelpLoadError());
} }
} }
Stream<HelpState> _mapGetHelpArticleState(GetHelpArticleEvent event) async* { void _mapGetHelpArticleState(
yield HelpLoading(); GetHelpArticleEvent event, Emitter<HelpState> emit) async {
emit(HelpLoading());
try { try {
final List<HelpArticle> categoryList = final List<HelpArticle> categoryList =
await helpRepository.getCategoryArticles(event.categoryId); await helpRepository.getCategoryArticles(event.categoryId);
yield HelpArticleState(categoryList); emit(HelpArticleState(categoryList));
} catch (error) { } catch (error) {
print(error); print(error);
yield HelpLoadError(); emit(HelpLoadError());
} }
} }
} }

@ -7,56 +7,43 @@ class LeaveMsgBloc extends Bloc<LeaveMsgEvent, LeaveMsgState> {
// //
final LeaveMsgRepository leaveMsgRepository = new LeaveMsgRepository(); final LeaveMsgRepository leaveMsgRepository = new LeaveMsgRepository();
LeaveMsgBloc() : super(new UnLeaveMsgState()); LeaveMsgBloc() : super(new UnLeaveMsgState()) {
on<SubmitLeaveMsgEvent>(_mapSubmitLeaveMsgToState);
@override on<UploadImageEvent>(_mapUploadImageToState);
Stream<LeaveMsgState> mapEventToState(
LeaveMsgEvent event,
) async* {
// if (event is GetLeaveMsgCategoryEvent) {
// yield* _mapGetLeaveMsgCategoryToState(event);
// } else
if (event is SubmitLeaveMsgEvent) {
yield* _mapSubmitLeaveMsgToState(event);
} else if (event is UploadImageEvent) {
yield* _mapUploadImageToState(event);
}
} }
// Stream<LeaveMsgState> _mapGetLeaveMsgCategoryToState( // @override
// GetLeaveMsgCategoryEvent event) async* { // Stream<LeaveMsgState> mapEventToState(
// yield LeaveMsgLoading(); // LeaveMsgEvent event,
// try { // ) async* {
// final List<HelpCategory> categoryList = // if (event is SubmitLeaveMsgEvent) {
// await leaveMsgRepository.getHelpLeaveMsgCategories(event.uid); // yield* _mapSubmitLeaveMsgToState(event);
// yield LeaveMsgCategoryState(categoryList); // } else if (event is UploadImageEvent) {
// } catch (error) { // yield* _mapUploadImageToState(event);
// print(error);
// yield LeaveMsgLoadError();
// } // }
// } // }
Stream<LeaveMsgState> _mapSubmitLeaveMsgToState( void _mapSubmitLeaveMsgToState(
SubmitLeaveMsgEvent event) async* { SubmitLeaveMsgEvent event, Emitter<LeaveMsgState> emit) async {
yield LeaveMsgSubmiting(); emit(LeaveMsgSubmiting());
try { try {
// final JsonResult jsonResult = // final JsonResult jsonResult =
await leaveMsgRepository.submitLeaveMsg(event.content, event.imageUrls); await leaveMsgRepository.submitLeaveMsg(event.content, event.imageUrls);
yield LeaveMsgSubmitSuccessState(); emit(LeaveMsgSubmitSuccessState());
} catch (error) { } catch (error) {
print(error); print(error);
yield LeaveMsgSubmitError(); emit(LeaveMsgSubmitError());
} }
} }
Stream<LeaveMsgState> _mapUploadImageToState(UploadImageEvent event) async* { void _mapUploadImageToState(UploadImageEvent event, Emitter<LeaveMsgState> emit) async {
yield ImageUploading(); emit(ImageUploading());
try { try {
final String url = await leaveMsgRepository.upload(event.filePath); final String url = await leaveMsgRepository.upload(event.filePath);
yield UploadImageSuccess(url); emit(UploadImageSuccess(url));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
} }

@ -1,4 +1,4 @@
import 'dart:async'; // import 'dart:async';
import 'package:bytedesk_kefu/model/codeResult.dart'; import 'package:bytedesk_kefu/model/codeResult.dart';
import 'package:bytedesk_kefu/model/jsonResult.dart'; import 'package:bytedesk_kefu/model/jsonResult.dart';
import 'package:bytedesk_kefu/model/oauth.dart'; import 'package:bytedesk_kefu/model/oauth.dart';
@ -10,172 +10,179 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
// //
final UserRepository _userRepository = new UserRepository(); final UserRepository _userRepository = new UserRepository();
LoginBloc() : super(LoginInitial()); LoginBloc() : super(LoginInitial()) {
on<LoginButtonPressed>(_mapLoginState);
@override on<SMSLoginButtonPressed>(_mapSMSLoginState);
Stream<LoginState> mapEventToState(LoginEvent event) async* { on<RegisterButtonPressed>(_mapRegisterState);
// on<RequestCodeButtonPressed>(_mapRequestCodeState);
if (event is LoginButtonPressed) { on<BindMobileEvent>(_mapBindMobileState);
yield* _mapLoginState(event); on<UnionidOAuthEvent>(_mapUnionidOAuthState);
} else if (event is SMSLoginButtonPressed) { on<ResetPasswordButtonPressed>(_mapResetPasswordState);
yield* _mapSMSLoginState(event); on<UpdatePasswordButtonPressed>(_mapUpdatePasswordState);
} else if (event is RegisterButtonPressed) {
yield* _mapRegisterState(event);
} else if (event is RequestCodeButtonPressed) {
yield* _mapRequestCodeState(event);
} else if (event is BindMobileEvent) {
yield* _mapBindMobileState(event);
} else if (event is UnionidOAuthEvent) {
yield* _mapUnionidOAuthState(event);
} else if (event is ResetPasswordButtonPressed) {
yield* _mapResetPasswordState(event);
} else if (event is UpdatePasswordButtonPressed) {
yield* _mapUpdatePasswordState(event);
}
} }
Stream<LoginState> _mapLoginState(LoginButtonPressed event) async* { // @override
yield LoginInProgress(); // void mapEventToState(LoginEvent event, Emitter<LoginState> emit) async {
// //
// if (event is LoginButtonPressed) {
// yield* _mapLoginState(event);
// } else if (event is SMSLoginButtonPressed) {
// yield* _mapSMSLoginState(event);
// } else if (event is RegisterButtonPressed) {
// yield* _mapRegisterState(event);
// } else if (event is RequestCodeButtonPressed) {
// yield* _mapRequestCodeState(event);
// } else if (event is BindMobileEvent) {
// yield* _mapBindMobileState(event);
// } else if (event is UnionidOAuthEvent) {
// yield* _mapUnionidOAuthState(event);
// } else if (event is ResetPasswordButtonPressed) {
// yield* _mapResetPasswordState(event);
// } else if (event is UpdatePasswordButtonPressed) {
// yield* _mapUpdatePasswordState(event);
// }
// }
void _mapLoginState(LoginButtonPressed event, Emitter<LoginState> emit) async {
emit(LoginInProgress());
try { try {
OAuth oauth = await _userRepository.login(event.username, event.password); OAuth oauth = await _userRepository.login(event.username, event.password);
if (oauth.statusCode == 200) { if (oauth.statusCode == 200) {
// //
yield LoginSuccess(); emit(LoginSuccess());
} else { } else {
// //
yield LoginError(); emit(LoginError());
} }
} catch (error) { } catch (error) {
// //
yield LoginFailure(error: error.toString()); emit(LoginFailure(error: error.toString()));
} }
} }
Stream<LoginState> _mapSMSLoginState(SMSLoginButtonPressed event) async* { void _mapSMSLoginState(SMSLoginButtonPressed event, Emitter<LoginState> emit) async {
yield LoginInProgress(); emit(LoginInProgress());
try { try {
// //
OAuth oauth = await _userRepository.smsOAuth(event.mobile, event.code); OAuth oauth = await _userRepository.smsOAuth(event.mobile, event.code);
if (oauth.statusCode == 200) { if (oauth.statusCode == 200) {
// //
yield SMSLoginSuccess(); emit(SMSLoginSuccess());
} else { } else {
// //
yield LoginError(); emit(LoginError());
} }
} catch (error) { } catch (error) {
// //
yield LoginFailure(error: error.toString()); emit(LoginFailure(error: error.toString()));
} }
} }
Stream<LoginState> _mapRegisterState(RegisterButtonPressed event) async* { void _mapRegisterState(RegisterButtonPressed event, Emitter<LoginState> emit) async {
yield RegisterInProgress(); emit(RegisterInProgress());
try { try {
// //
JsonResult jsonResult = JsonResult jsonResult =
await _userRepository.register(event.mobile, event.password); await _userRepository.register(event.mobile, event.password);
if (jsonResult.statusCode == 200) { if (jsonResult.statusCode == 200) {
yield RegisterSuccess(); emit(RegisterSuccess());
} else { } else {
yield RegisterError( emit(RegisterError(
message: jsonResult.message, statusCode: jsonResult.statusCode); message: jsonResult.message, statusCode: jsonResult.statusCode));
} }
} catch (error) { } catch (error) {
// //
yield LoginFailure(error: error.toString()); emit(LoginFailure(error: error.toString()));
} }
} }
Stream<LoginState> _mapRequestCodeState( void _mapRequestCodeState(RequestCodeButtonPressed event, Emitter<LoginState> emit) async {
RequestCodeButtonPressed event) async* { emit(RequestCodeInProgress());
yield RequestCodeInProgress();
try { try {
// //
CodeResult codeResult = await _userRepository.requestCode(event.mobile); CodeResult codeResult = await _userRepository.requestCode(event.mobile);
if (codeResult.statusCode == 200) { if (codeResult.statusCode == 200) {
yield RequestCodeSuccess(codeResult: codeResult); emit(RequestCodeSuccess(codeResult: codeResult));
} else { } else {
yield RequestCodeError( emit(RequestCodeError(
message: codeResult.message, statusCode: codeResult.statusCode); message: codeResult.message, statusCode: codeResult.statusCode));
} }
} catch (error) { } catch (error) {
// //
yield LoginFailure(error: error.toString()); emit(LoginFailure(error: error.toString()));
} }
} }
Stream<LoginState> _mapBindMobileState(BindMobileEvent event) async* { void _mapBindMobileState(BindMobileEvent event, Emitter<LoginState> emit) async {
yield BindMobileInProgress(); emit(BindMobileInProgress());
try { try {
// //
JsonResult jsonResult = await _userRepository.bindMobile(event.mobile); JsonResult jsonResult = await _userRepository.bindMobile(event.mobile);
if (jsonResult.statusCode == 200) { if (jsonResult.statusCode == 200) {
yield BindMobileSuccess(jsonResult: jsonResult); emit(BindMobileSuccess(jsonResult: jsonResult));
} else { } else {
yield BindMobileError( emit(BindMobileError(
message: jsonResult.message, statusCode: jsonResult.statusCode); message: jsonResult.message, statusCode: jsonResult.statusCode));
} }
} catch (error) { } catch (error) {
// //
yield LoginFailure(error: error.toString()); emit(LoginFailure(error: error.toString()));
} }
} }
Stream<LoginState> _mapUnionidOAuthState(UnionidOAuthEvent event) async* { void _mapUnionidOAuthState(UnionidOAuthEvent event, Emitter<LoginState> emit) async {
yield UnionidOAuthInProgress(); emit(UnionidOAuthInProgress());
try { try {
// //
OAuth oauth = await _userRepository.unionIdOAuth(event.unionid); OAuth oauth = await _userRepository.unionIdOAuth(event.unionid);
if (oauth.statusCode == 200) { if (oauth.statusCode == 200) {
// //
yield UnionidLoginSuccess(); emit(UnionidLoginSuccess());
} else { } else {
// //
yield LoginError(); emit(LoginError());
} }
} catch (error) { } catch (error) {
// //
yield LoginFailure(error: error.toString()); emit(LoginFailure(error: error.toString()));
} }
} }
Stream<LoginState> _mapResetPasswordState( void _mapResetPasswordState(ResetPasswordButtonPressed event, Emitter<LoginState> emit) async {
ResetPasswordButtonPressed event) async* { emit(ResetPasswordInProgress());
yield ResetPasswordInProgress();
try { try {
// //
JsonResult jsonResult = JsonResult jsonResult =
await _userRepository.changePassword(event.mobile, event.password); await _userRepository.changePassword(event.mobile, event.password);
if (jsonResult.statusCode == 200) { if (jsonResult.statusCode == 200) {
yield ResetPasswordSuccess(); emit(ResetPasswordSuccess());
} else { } else {
yield ResetPasswordError( emit(ResetPasswordError(
message: jsonResult.message, statusCode: jsonResult.statusCode); message: jsonResult.message, statusCode: jsonResult.statusCode));
} }
} catch (error) { } catch (error) {
// //
yield LoginFailure(error: error.toString()); emit(LoginFailure(error: error.toString()));
} }
} }
Stream<LoginState> _mapUpdatePasswordState( void _mapUpdatePasswordState(UpdatePasswordButtonPressed event, Emitter<LoginState> emit) async {
UpdatePasswordButtonPressed event) async* {
// //
yield UpdatePasswordInProgress(); emit(UpdatePasswordInProgress());
try { try {
// //
JsonResult jsonResult = JsonResult jsonResult =
await _userRepository.changePassword(event.mobile, event.password); await _userRepository.changePassword(event.mobile, event.password);
if (jsonResult.statusCode == 200) { if (jsonResult.statusCode == 200) {
yield UpdatePasswordSuccess(); emit(UpdatePasswordSuccess());
} else { } else {
yield UpdatePasswordError( emit(UpdatePasswordError(
message: jsonResult.message, statusCode: jsonResult.statusCode); message: jsonResult.message, statusCode: jsonResult.statusCode));
} }
} catch (error) { } catch (error) {
// //
yield LoginFailure(error: error.toString()); emit(LoginFailure(error: error.toString()));
} }
} }
} }

@ -1,4 +1,4 @@
import 'dart:async'; // import 'dart:async';
import 'package:bytedesk_kefu/model/jsonResult.dart'; import 'package:bytedesk_kefu/model/jsonResult.dart';
import 'package:bytedesk_kefu/model/message.dart'; import 'package:bytedesk_kefu/model/message.dart';
import 'package:bytedesk_kefu/model/requestAnswer.dart'; import 'package:bytedesk_kefu/model/requestAnswer.dart';
@ -11,154 +11,160 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
// //
final MessageRepository messageRepository = new MessageRepository(); final MessageRepository messageRepository = new MessageRepository();
MessageBloc() : super(InitialMessageState()); MessageBloc() : super(InitialMessageState()) {
on<ReceiveMessageEvent>(_mapRefreshCourseToState);
on<UploadImageEvent>(_mapUploadImageToState);
on<UploadVideoEvent>(_mapUploadVideoToState);
on<SendMessageRestEvent>(_mapSendMessageRestToState);
on<LoadHistoryMessageEvent>(_mapLoadHistoryMessageToState);
on<LoadTopicMessageEvent>(_mapLoadTopicMessageToState);
@override on<LoadChannelMessageEvent>(_mapLoadChannelMessageToState);
Stream<MessageState> mapEventToState(MessageEvent event) async* { on<QueryAnswerEvent>(_mapQueryAnswerToState);
if (event is ReceiveMessageEvent) { on<MessageAnswerEvent>(_mapMessageAnswerToState);
yield* _mapRefreshCourseToState(event); on<RateAnswerEvent>(_mapRateAnswerToState);
} else if (event is UploadImageEvent) {
yield* _mapUploadImageToState(event);
} else if (event is UploadVideoEvent) {
yield* _mapUploadVideoToState(event);
} else if (event is QueryAnswerEvent) {
yield* _mapQueryAnswerToState(event);
} else if (event is MessageAnswerEvent) {
yield* _mapMessageAnswerToState(event);
} else if (event is RateAnswerEvent) {
yield* _mapRateAnswerToState(event);
} else if (event is LoadHistoryMessageEvent) {
yield* _mapLoadHistoryMessageToState(event);
} else if (event is LoadTopicMessageEvent) {
yield* _mapLoadTopicMessageToState(event);
} else if (event is LoadChannelMessageEvent) {
yield* _mapLoadChannelMessageToState(event);
} else if (event is SendMessageRestEvent) {
yield* _mapSendMessageRestToState(event);
}
} }
Stream<MessageState> _mapRefreshCourseToState( // @override
ReceiveMessageEvent event) async* { // void mapEventToState(MessageEvent event, Emitter<MessageState> emit) async {
// if (event is ReceiveMessageEvent) {
// yield* _mapRefreshCourseToState(event);
// } else if (event is UploadImageEvent) {
// yield* _mapUploadImageToState(event);
// } else if (event is UploadVideoEvent) {
// yield* _mapUploadVideoToState(event);
// } else if (event is QueryAnswerEvent) {
// yield* _mapQueryAnswerToState(event);
// } else if (event is MessageAnswerEvent) {
// yield* _mapMessageAnswerToState(event);
// } else if (event is RateAnswerEvent) {
// yield* _mapRateAnswerToState(event);
// } else if (event is LoadHistoryMessageEvent) {
// yield* _mapLoadHistoryMessageToState(event);
// } else if (event is LoadTopicMessageEvent) {
// yield* _mapLoadTopicMessageToState(event);
// } else if (event is LoadChannelMessageEvent) {
// yield* _mapLoadChannelMessageToState(event);
// } else if (event is SendMessageRestEvent) {
// yield* _mapSendMessageRestToState(event);
// }
// }
void _mapRefreshCourseToState(ReceiveMessageEvent event, Emitter<MessageState> emit) async {
try { try {
yield ReceiveMessageState(message: event.message); emit(ReceiveMessageState(message: event.message));
} catch (error) { } catch (error) {
print(error); print(error);
} }
} }
Stream<MessageState> _mapUploadImageToState(UploadImageEvent event) async* { void _mapUploadImageToState(UploadImageEvent event, Emitter<MessageState> emit) async {
yield MessageUpLoading(); emit(MessageUpLoading());
try { try {
final UploadJsonResult uploadJsonResult = final UploadJsonResult uploadJsonResult =
await messageRepository.uploadImage(event.filePath); await messageRepository.uploadImage(event.filePath);
yield UploadImageSuccess(uploadJsonResult); emit(UploadImageSuccess(uploadJsonResult));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<MessageState> _mapUploadVideoToState(UploadVideoEvent event) async* { void _mapUploadVideoToState(UploadVideoEvent event, Emitter<MessageState> emit) async {
yield MessageUpLoading(); emit(MessageUpLoading());
try { try {
final UploadJsonResult uploadJsonResult = final UploadJsonResult uploadJsonResult =
await messageRepository.uploadVideo(event.filePath); await messageRepository.uploadVideo(event.filePath);
yield UploadVideoSuccess(uploadJsonResult); emit(UploadVideoSuccess(uploadJsonResult));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<MessageState> _mapSendMessageRestToState( void _mapSendMessageRestToState(SendMessageRestEvent event, Emitter<MessageState> emit) async {
SendMessageRestEvent event) async* { emit(RestMessageSending());
yield RestMessageSending();
try { try {
final JsonResult jsonResult = final JsonResult jsonResult =
await messageRepository.sendMessageRest(event.json); await messageRepository.sendMessageRest(event.json);
yield SendMessageRestSuccess(jsonResult); emit(SendMessageRestSuccess(jsonResult));
} catch (error) { } catch (error) {
print(error); print(error);
yield SendMessageRestError(); emit(SendMessageRestError());
} }
} }
Stream<MessageState> _mapLoadHistoryMessageToState( void _mapLoadHistoryMessageToState(LoadHistoryMessageEvent event, Emitter<MessageState> emit) async {
LoadHistoryMessageEvent event) async* { emit(MessageLoading());
yield MessageLoading();
try { try {
final List<Message> messageList = await messageRepository final List<Message> messageList = await messageRepository
.loadHistoryMessages(event.uid, event.page, event.size); .loadHistoryMessages(event.uid, event.page, event.size);
yield LoadHistoryMessageSuccess(messageList: messageList); emit(LoadHistoryMessageSuccess(messageList: messageList));
} catch (error) { } catch (error) {
print(error); print(error);
yield LoadHistoryMessageError(); emit(LoadHistoryMessageError());
} }
} }
Stream<MessageState> _mapLoadTopicMessageToState( void _mapLoadTopicMessageToState(LoadTopicMessageEvent event, Emitter<MessageState> emit) async {
LoadTopicMessageEvent event) async* { emit(MessageLoading());
yield MessageLoading();
try { try {
final List<Message> messageList = await messageRepository final List<Message> messageList = await messageRepository
.loadTopicMessages(event.topic, event.page, event.size); .loadTopicMessages(event.topic, event.page, event.size);
yield LoadTopicMessageSuccess(messageList: messageList); emit(LoadTopicMessageSuccess(messageList: messageList));
} catch (error) { } catch (error) {
print(error); print(error);
yield LoadTopicMessageError(); emit(LoadTopicMessageError());
} }
} }
Stream<MessageState> _mapLoadChannelMessageToState( void _mapLoadChannelMessageToState(LoadChannelMessageEvent event, Emitter<MessageState> emit) async {
LoadChannelMessageEvent event) async* { emit(MessageLoading());
yield MessageLoading();
try { try {
final List<Message> messageList = await messageRepository final List<Message> messageList = await messageRepository
.loadChannelMessages(event.cid, event.page, event.size); .loadChannelMessages(event.cid, event.page, event.size);
yield LoadChannelMessageSuccess(messageList: messageList); emit(LoadChannelMessageSuccess(messageList: messageList));
} catch (error) { } catch (error) {
print(error); print(error);
yield LoadChannelMessageError(); emit(LoadChannelMessageError());
} }
} }
Stream<MessageState> _mapQueryAnswerToState(QueryAnswerEvent event) async* { void _mapQueryAnswerToState(QueryAnswerEvent event, Emitter<MessageState> emit) async {
yield MessageLoading(); emit(MessageLoading());
try { try {
final RequestAnswerResult requestAnswerResult = final RequestAnswerResult requestAnswerResult =
await messageRepository.queryAnswer(event.tid, event.aid); await messageRepository.queryAnswer(event.tid, event.aid);
yield QueryAnswerSuccess( emit(QueryAnswerSuccess(
query: requestAnswerResult.query, answer: requestAnswerResult.anwser); query: requestAnswerResult.query, answer: requestAnswerResult.anwser));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<MessageState> _mapMessageAnswerToState( void _mapMessageAnswerToState(MessageAnswerEvent event, Emitter<MessageState> emit) async {
MessageAnswerEvent event) async* { emit(MessageLoading());
yield MessageLoading();
try { try {
final RequestAnswerResult requestAnswerResult = await messageRepository final RequestAnswerResult requestAnswerResult = await messageRepository
.messageAnswer(event.type, event.wid, event.aid, event.content); .messageAnswer(event.type, event.wid, event.aid, event.content);
yield MessageAnswerSuccess( emit(MessageAnswerSuccess(
query: requestAnswerResult.query, answer: requestAnswerResult.anwser); query: requestAnswerResult.query, answer: requestAnswerResult.anwser));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<MessageState> _mapRateAnswerToState(RateAnswerEvent event) async* { void _mapRateAnswerToState(RateAnswerEvent event, Emitter<MessageState> emit) async {
yield MessageLoading(); emit(MessageLoading());
try { try {
final RequestAnswerResult requestAnswerResult = final RequestAnswerResult requestAnswerResult =
await messageRepository.rateAnswer(event.aid, event.mid, event.rate); await messageRepository.rateAnswer(event.aid, event.mid, event.rate);
yield RateAnswerSuccess(result: requestAnswerResult.anwser); emit(RateAnswerSuccess(result: requestAnswerResult.anwser));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
} }

@ -9,172 +9,184 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
// //
final UserRepository userRepository = new UserRepository(); final UserRepository userRepository = new UserRepository();
ProfileBloc() : super(InitialProfileState()); ProfileBloc() : super(InitialProfileState()) {
on<GetProfileEvent>(_mapProfileState);
on<UploadImageEvent>(_mapUploadImageToState);
on<UpdateAvatarEvent>(_mapUpdateAvatarToState);
on<UpdateNicknameEvent>(_mapUpdateNicknameToState);
on<UpdateDescriptionEvent>(_mapUpdateDescriptionToState);
on<UpdateMobileEvent>(_mapUpdateMobileToState);
@override on<UpdateSexEvent>(_mapUpdateSexToState);
Stream<ProfileState> mapEventToState(ProfileEvent event) async* { on<UpdateLocationEvent>(_mapUpdateLocationToState);
// on<UpdateBirthdayEvent>(_mapUpdateBirthdayToState);
if (event is GetProfileEvent) { on<QueryFollowEvent>(_mapQueryFollowToState);
yield* _mapProfileState(); on<UserFollowEvent>(_mapUserFollowToState);
} else if (event is UploadImageEvent) {
yield* _mapUploadImageToState(event); on<UserUnfollowEvent>(_mapUserUnfollowToState);
} else if (event is UpdateAvatarEvent) {
yield* _mapUpdateAvatarToState(event); }
} else if (event is UpdateNicknameEvent) {
yield* _mapUpdateNicknameToState(event); // @override
} else if (event is UpdateDescriptionEvent) { // void mapEventToState(ProfileEvent event, Emitter<ProfileState> emit) async {
yield* _mapUpdateDescriptionToState(event); // //
} else if (event is UpdateMobileEvent) { // if (event is GetProfileEvent) {
yield* _mapUpdateMobileToState(event); // yield* _mapProfileState();
} else if (event is UpdateSexEvent) { // } else if (event is UploadImageEvent) {
yield* _mapUpdateSexToState(event); // yield* _mapUploadImageToState(event);
} else if (event is UpdateLocationEvent) { // } else if (event is UpdateAvatarEvent) {
yield* _mapUpdateLocationToState(event); // yield* _mapUpdateAvatarToState(event);
} else if (event is UpdateBirthdayEvent) { // } else if (event is UpdateNicknameEvent) {
yield* _mapUpdateBirthdayToState(event); // yield* _mapUpdateNicknameToState(event);
} else if (event is QueryFollowEvent) { // } else if (event is UpdateDescriptionEvent) {
yield* _mapQueryFollowToState(event); // yield* _mapUpdateDescriptionToState(event);
} else if (event is UserFollowEvent) { // } else if (event is UpdateMobileEvent) {
yield* _mapUserFollowToState(event); // yield* _mapUpdateMobileToState(event);
} else if (event is UserUnfollowEvent) { // } else if (event is UpdateSexEvent) {
yield* _mapUserUnfollowToState(event); // yield* _mapUpdateSexToState(event);
} // } else if (event is UpdateLocationEvent) {
} // yield* _mapUpdateLocationToState(event);
// } else if (event is UpdateBirthdayEvent) {
Stream<ProfileState> _mapProfileState() async* { // yield* _mapUpdateBirthdayToState(event);
yield ProfileInProgress(); // } else if (event is QueryFollowEvent) {
// yield* _mapQueryFollowToState(event);
// } else if (event is UserFollowEvent) {
// yield* _mapUserFollowToState(event);
// } else if (event is UserUnfollowEvent) {
// yield* _mapUserUnfollowToState(event);
// }
// }
void _mapProfileState(GetProfileEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try { try {
User user = await userRepository.getProfile(); User user = await userRepository.getProfile();
yield ProfileSuccess(user: user); emit(ProfileSuccess(user: user));
} catch (error) { } catch (error) {
// //
yield ProfileFailure(error: error.toString()); emit(ProfileFailure(error: error.toString()));
} }
} }
Stream<ProfileState> _mapUploadImageToState(UploadImageEvent event) async* { void _mapUploadImageToState(UploadImageEvent event, Emitter<ProfileState> emit) async {
yield ProfileInProgress(); emit(ProfileInProgress());
try { try {
final String url = await userRepository.upload(event.filePath); final String url = await userRepository.upload(event.filePath);
yield UploadImageSuccess(url); emit(UploadImageSuccess(url));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<ProfileState> _mapUpdateAvatarToState(UpdateAvatarEvent event) async* { void _mapUpdateAvatarToState(UpdateAvatarEvent event, Emitter<ProfileState> emit) async {
yield ProfileInProgress(); emit(ProfileInProgress());
try { try {
final User user = await userRepository.updateAvatar(event.avatar); final User user = await userRepository.updateAvatar(event.avatar);
yield UpdateAvatarSuccess(user); emit(UpdateAvatarSuccess(user));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<ProfileState> _mapUpdateNicknameToState( void _mapUpdateNicknameToState(UpdateNicknameEvent event, Emitter<ProfileState> emit) async {
UpdateNicknameEvent event) async* { emit(ProfileInProgress());
yield ProfileInProgress();
try { try {
final User user = await userRepository.updateNickname(event.nickname); final User user = await userRepository.updateNickname(event.nickname);
yield UpdateNicknameSuccess(user); emit(UpdateNicknameSuccess(user));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<ProfileState> _mapUpdateDescriptionToState( void _mapUpdateDescriptionToState(UpdateDescriptionEvent event, Emitter<ProfileState> emit) async {
UpdateDescriptionEvent event) async* { emit(ProfileInProgress());
yield ProfileInProgress();
try { try {
final User user = final User user =
await userRepository.updateDescription(event.description); await userRepository.updateDescription(event.description);
yield UpdateDescriptionSuccess(user); emit(UpdateDescriptionSuccess(user));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<ProfileState> _mapUpdateMobileToState(UpdateMobileEvent event) async* { void _mapUpdateMobileToState(UpdateMobileEvent event, Emitter<ProfileState> emit) async {
yield ProfileInProgress(); emit(ProfileInProgress());
try { try {
final User user = await userRepository.updateMobile(event.mobile); final User user = await userRepository.updateMobile(event.mobile);
yield UpdateMobileSuccess(user); emit(UpdateMobileSuccess(user));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<ProfileState> _mapUpdateSexToState(UpdateSexEvent event) async* { void _mapUpdateSexToState(UpdateSexEvent event, Emitter<ProfileState> emit) async {
yield ProfileInProgress(); emit(ProfileInProgress());
try { try {
final User user = await userRepository.updateSex(event.sex); final User user = await userRepository.updateSex(event.sex);
yield UpdateSexSuccess(user); emit(UpdateSexSuccess(user));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<ProfileState> _mapUpdateLocationToState( void _mapUpdateLocationToState(UpdateLocationEvent event, Emitter<ProfileState> emit) async {
UpdateLocationEvent event) async* { emit(ProfileInProgress());
yield ProfileInProgress();
try { try {
final User user = await userRepository.updateLocation(event.location); final User user = await userRepository.updateLocation(event.location);
yield UpdateLocationSuccess(user); emit(UpdateLocationSuccess(user));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<ProfileState> _mapUpdateBirthdayToState( void _mapUpdateBirthdayToState(UpdateBirthdayEvent event, Emitter<ProfileState> emit) async {
UpdateBirthdayEvent event) async* { emit(ProfileInProgress());
yield ProfileInProgress();
try { try {
final User user = await userRepository.updateBirthday(event.birthday); final User user = await userRepository.updateBirthday(event.birthday);
yield UpdateBirthdaySuccess(user); emit(UpdateBirthdaySuccess(user));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
Stream<ProfileState> _mapQueryFollowToState(QueryFollowEvent event) async* { void _mapQueryFollowToState(QueryFollowEvent event, Emitter<ProfileState> emit) async {
yield QueryFollowing(); emit(QueryFollowing());
try { try {
final bool isFollowed = await userRepository.isFollowed(event.uid); final bool isFollowed = await userRepository.isFollowed(event.uid);
yield QueryFollowSuccess(isFollowed); emit(QueryFollowSuccess(isFollowed));
} catch (error) { } catch (error) {
print(error); print(error);
yield QueryFollowError(); emit(QueryFollowError());
} }
} }
Stream<ProfileState> _mapUserFollowToState(UserFollowEvent event) async* { void _mapUserFollowToState(UserFollowEvent event, Emitter<ProfileState> emit) async {
yield Following(); emit(Following());
try { try {
final JsonResult jsonResult = await userRepository.follow(event.uid); final JsonResult jsonResult = await userRepository.follow(event.uid);
yield FollowResultSuccess(jsonResult); emit(FollowResultSuccess(jsonResult));
} catch (error) { } catch (error) {
print(error); print(error);
yield FollowError(); emit(FollowError());
} }
} }
Stream<ProfileState> _mapUserUnfollowToState(UserUnfollowEvent event) async* { void _mapUserUnfollowToState(UserUnfollowEvent event, Emitter<ProfileState> emit) async {
yield Following(); emit(Following());
try { try {
final JsonResult jsonResult = await userRepository.unfollow(event.uid); final JsonResult jsonResult = await userRepository.unfollow(event.uid);
yield UnfollowResultSuccess(jsonResult); emit(UnfollowResultSuccess(jsonResult));
} catch (error) { } catch (error) {
print(error); print(error);
yield UnFollowError(); emit(UnFollowError());
} }
} }
} }

@ -1,4 +1,4 @@
import 'dart:async'; // import 'dart:async';
import 'package:bytedesk_kefu/model/markThread.dart'; import 'package:bytedesk_kefu/model/markThread.dart';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import './bloc.dart'; import './bloc.dart';
@ -9,234 +9,219 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
// //
final ThreadRepository threadRepository = new ThreadRepository(); final ThreadRepository threadRepository = new ThreadRepository();
ThreadBloc() : super(ThreadEmpty()); // ThreadBloc() : super(ThreadEmpty());
@override ThreadBloc() : super(ThreadEmpty()) {
Stream<ThreadState> mapEventToState(ThreadEvent event) async* { // on<InitThreadEvent>(InitialThreadState);
// on<RefreshThreadEvent>(_mapRefreshThreadToState);
if (event is InitThreadEvent) { on<RefreshHistoryThreadEvent>(_mapRefreshHistoryThreadToState);
yield InitialThreadState(); on<RefreshVisitorThreadEvent>(_mapRefreshVisitorThreadToState);
} else if (event is RefreshThreadEvent) { on<RefreshVisitorThreadAllEvent>(_mapRefreshVisitorThreadAllToState);
yield* _mapRefreshThreadToState(event); on<RequestThreadEvent>(_mapRequestThreadToState);
} else if (event is RefreshHistoryThreadEvent) {
yield* _mapRefreshHistoryThreadToState(event); on<RequestAgentEvent>(_mapRequestAgentToState);
} else if (event is RefreshVisitorThreadEvent) { on<RequestContactThreadEvent>(_mapRequestContactThreadToState);
yield* _mapRefreshVisitorThreadToState(event); on<RequestGroupThreadEvent>(_mapRequestGroupThreadToState);
} else if (event is RefreshVisitorThreadAllEvent) { on<MarkTopThreadEvent>(_mapMarkTopThreadEventToState);
yield* _mapRefreshVisitorThreadAllToState(event); on<UnMarkTopThreadEvent>(_mapUnMarkTopThreadEventToState);
} else if (event is RequestThreadEvent) {
yield* _mapRequestThreadToState(event); on<MarkNodisturbThreadEvent>(_mapMarkNodisturbThreadEventToState);
} else if (event is RequestAgentEvent) { on<UnMarkNodisturbThreadEvent>(_mapUnMarkNodisturbThreadEventToState);
yield* _mapRequestAgentToState(event); on<MarkUnreadThreadEvent>(_mapMarkUnreadThreadEventToState);
} else if (event is RequestContactThreadEvent) { on<UnMarkUnreadThreadEvent>(_mapUnMarkUnreadThreadEventToState);
yield* _mapRequestContactThreadToState(event); on<DeleteThreadEvent>(_mapDeleteThreadEventToState);
} else if (event is RequestGroupThreadEvent) { }
yield* _mapRequestGroupThreadToState(event);
} else if (event is MarkTopThreadEvent) { void _mapRefreshThreadToState(
yield* _mapMarkTopThreadEventToState(event); RefreshThreadEvent event, Emitter<ThreadState> emit) async {
} else if (event is UnMarkTopThreadEvent) { emit(ThreadLoading());
yield* _mapUnMarkTopThreadEventToState(event);
} else if (event is MarkNodisturbThreadEvent) {
yield* _mapMarkNodisturbThreadEventToState(event);
} else if (event is UnMarkNodisturbThreadEvent) {
yield* _mapUnMarkNodisturbThreadEventToState(event);
} else if (event is MarkUnreadThreadEvent) {
yield* _mapMarkUnreadThreadEventToState(event);
} else if (event is UnMarkUnreadThreadEvent) {
yield* _mapUnMarkUnreadThreadEventToState(event);
} else if (event is DeleteThreadEvent) {
yield* _mapDeleteThreadEventToState(event);
}
}
Stream<ThreadState> _mapRefreshThreadToState(
RefreshThreadEvent event) async* {
yield ThreadLoading();
try { try {
final List<Thread> threadList = await threadRepository.getThreads(); final List<Thread> threadList = await threadRepository.getThreads();
yield ThreadLoadSuccess(threadList); emit(ThreadLoadSuccess(threadList));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapRefreshHistoryThreadToState( void _mapRefreshHistoryThreadToState(
RefreshHistoryThreadEvent event) async* { RefreshHistoryThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadHistoryLoading(); emit(ThreadHistoryLoading());
try { try {
final List<Thread> threadList = final List<Thread> threadList =
await threadRepository.getHistoryThreads(event.page, event.size); await threadRepository.getHistoryThreads(event.page, event.size);
yield ThreadLoadSuccess(threadList); emit(ThreadLoadSuccess(threadList));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapRefreshVisitorThreadToState( void _mapRefreshVisitorThreadToState(
RefreshVisitorThreadEvent event) async* { RefreshVisitorThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadVisitorLoading(); emit(ThreadVisitorLoading());
try { try {
final List<Thread> threadList = final List<Thread> threadList =
await threadRepository.getVisitorThreads(event.page, event.size); await threadRepository.getVisitorThreads(event.page, event.size);
yield ThreadLoadSuccess(threadList); emit(ThreadLoadSuccess(threadList));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapRefreshVisitorThreadAllToState( void _mapRefreshVisitorThreadAllToState(
RefreshVisitorThreadAllEvent event) async* { RefreshVisitorThreadAllEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final List<Thread> threadList = final List<Thread> threadList =
await threadRepository.getVisitorThreadsAll(); await threadRepository.getVisitorThreadsAll();
yield ThreadLoadSuccess(threadList); emit(ThreadLoadSuccess(threadList));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapRequestThreadToState( void _mapRequestThreadToState(
RequestThreadEvent event) async* { RequestThreadEvent event, Emitter<ThreadState> emit) async {
yield RequestThreading(); print('RequestThreadEvent');
emit(RequestThreading());
try { try {
final RequestThreadResult thread = await threadRepository.requestThread( final RequestThreadResult thread = await threadRepository.requestThread(
event.wid, event.type, event.aid); event.wid, event.type, event.aid);
yield RequestThreadSuccess(thread); emit(RequestThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield RequestThreadError(); emit(RequestThreadError());
} }
} }
Stream<ThreadState> _mapRequestAgentToState(RequestAgentEvent event) async* { void _mapRequestAgentToState(
yield RequestAgentThreading(); RequestAgentEvent event, Emitter<ThreadState> emit) async {
emit(RequestAgentThreading());
try { try {
final RequestThreadResult thread = final RequestThreadResult thread =
await threadRepository.requestAgent(event.wid, event.type, event.aid); await threadRepository.requestAgent(event.wid, event.type, event.aid);
yield RequestAgentSuccess(thread); emit(RequestAgentSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield RequestAgentThreadError(); emit(RequestAgentThreadError());
} }
} }
Stream<ThreadState> _mapRequestContactThreadToState( void _mapRequestContactThreadToState(
RequestContactThreadEvent event) async* { RequestContactThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final RequestThreadResult thread = final RequestThreadResult thread =
await threadRepository.requestContactThread(event.cid); await threadRepository.requestContactThread(event.cid);
yield RequestContactThreadSuccess(thread); emit(RequestContactThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapRequestGroupThreadToState( void _mapRequestGroupThreadToState(
RequestGroupThreadEvent event) async* { RequestGroupThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final RequestThreadResult thread = final RequestThreadResult thread =
await threadRepository.requestGroupThread(event.gid); await threadRepository.requestGroupThread(event.gid);
yield RequestGroupThreadSuccess(thread); emit(RequestGroupThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapMarkTopThreadEventToState( void _mapMarkTopThreadEventToState(
MarkTopThreadEvent event) async* { MarkTopThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final MarkThreadResult thread = await threadRepository.markTop(event.tid); final MarkThreadResult thread = await threadRepository.markTop(event.tid);
yield MarkTopThreadSuccess(thread); emit(MarkTopThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapUnMarkTopThreadEventToState( void _mapUnMarkTopThreadEventToState(
UnMarkTopThreadEvent event) async* { UnMarkTopThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final MarkThreadResult thread = final MarkThreadResult thread =
await threadRepository.unmarkTop(event.tid); await threadRepository.unmarkTop(event.tid);
yield UnMarkTopThreadSuccess(thread); emit(UnMarkTopThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapMarkNodisturbThreadEventToState( void _mapMarkNodisturbThreadEventToState(
MarkNodisturbThreadEvent event) async* { MarkNodisturbThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final MarkThreadResult thread = final MarkThreadResult thread =
await threadRepository.markNodisturb(event.tid); await threadRepository.markNodisturb(event.tid);
yield MarkNodisturbThreadSuccess(thread); emit(MarkNodisturbThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapUnMarkNodisturbThreadEventToState( void _mapUnMarkNodisturbThreadEventToState(
UnMarkNodisturbThreadEvent event) async* { UnMarkNodisturbThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final MarkThreadResult thread = final MarkThreadResult thread =
await threadRepository.unmarkNodisturb(event.tid); await threadRepository.unmarkNodisturb(event.tid);
yield UnMarkNodisturbThreadSuccess(thread); emit(UnMarkNodisturbThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapMarkUnreadThreadEventToState( void _mapMarkUnreadThreadEventToState(
MarkUnreadThreadEvent event) async* { MarkUnreadThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final MarkThreadResult thread = final MarkThreadResult thread =
await threadRepository.markUnread(event.tid); await threadRepository.markUnread(event.tid);
yield MarkUnreadThreadSuccess(thread); emit(MarkUnreadThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapUnMarkUnreadThreadEventToState( void _mapUnMarkUnreadThreadEventToState(
UnMarkUnreadThreadEvent event) async* { UnMarkUnreadThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final MarkThreadResult thread = final MarkThreadResult thread =
await threadRepository.unmarkUnread(event.tid); await threadRepository.unmarkUnread(event.tid);
yield UnMarkUnreadThreadSuccess(thread); emit(UnMarkUnreadThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
Stream<ThreadState> _mapDeleteThreadEventToState( void _mapDeleteThreadEventToState(
DeleteThreadEvent event) async* { DeleteThreadEvent event, Emitter<ThreadState> emit) async {
yield ThreadLoading(); emit(ThreadLoading());
try { try {
final MarkThreadResult thread = await threadRepository.delete(event.tid); final MarkThreadResult thread = await threadRepository.delete(event.tid);
yield DeleteThreadSuccess(thread); emit(DeleteThreadSuccess(thread));
} catch (error) { } catch (error) {
print(error); print(error);
yield ThreadLoadError(); emit(ThreadLoadError());
} }
} }
} }

@ -9,7 +9,7 @@ abstract class ThreadEvent extends Equatable {
List<Object> get props => []; List<Object> get props => [];
} }
class InitThreadEvent extends ThreadEvent {} // class InitThreadEvent extends ThreadEvent {}
class RefreshThreadEvent extends ThreadEvent {} class RefreshThreadEvent extends ThreadEvent {}

@ -1,4 +1,4 @@
import 'dart:async'; // import 'dart:async';
import 'package:bytedesk_kefu/blocs/ticket_bloc/bloc.dart'; import 'package:bytedesk_kefu/blocs/ticket_bloc/bloc.dart';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/repositories/ticket_repository.dart'; import 'package:bytedesk_kefu/repositories/ticket_repository.dart';
@ -7,54 +7,57 @@ class TicketBloc extends Bloc<TicketEvent, TicketState> {
// //
final TicketRepository feedbackRepository = new TicketRepository(); final TicketRepository feedbackRepository = new TicketRepository();
TicketBloc() : super(new UnTicketState()); TicketBloc() : super(new UnTicketState()) {
on<GetTicketCategoryEvent>(_mapGetTicketCategoryToState);
@override on<SubmitTicketEvent>(_mapSubmitTicketToState);
Stream<TicketState> mapEventToState( on<UploadImageEvent>(_mapUploadImageToState);
TicketEvent event,
) async* {
if (event is GetTicketCategoryEvent) {
yield* _mapGetTicketCategoryToState(event);
} else if (event is SubmitTicketEvent) {
yield* _mapSubmitTicketToState(event);
} else if (event is UploadImageEvent) {
yield* _mapUploadImageToState(event);
}
} }
Stream<TicketState> _mapGetTicketCategoryToState( // @override
GetTicketCategoryEvent event) async* { // void mapEventToState(
yield TicketLoading(); // TicketEvent event,
// ) async* {
// if (event is GetTicketCategoryEvent) {
// yield* _mapGetTicketCategoryToState(event);
// } else if (event is SubmitTicketEvent) {
// yield* _mapSubmitTicketToState(event);
// } else if (event is UploadImageEvent) {
// yield* _mapUploadImageToState(event);
// }
// }
void _mapGetTicketCategoryToState(GetTicketCategoryEvent event, Emitter<TicketState> emit) async {
emit(TicketLoading());
try { try {
// final List<HelpCategory> categoryList = // final List<HelpCategory> categoryList =
// await feedbackRepository.getHelpTicketCategories(); // await feedbackRepository.getHelpTicketCategories();
// yield TicketCategoryState(categoryList); // emit(TicketCategoryState(categoryList);
} catch (error) { } catch (error) {
print(error); print(error);
yield TicketLoadError(); emit(TicketLoadError());
} }
} }
Stream<TicketState> _mapSubmitTicketToState(SubmitTicketEvent event) async* { void _mapSubmitTicketToState(SubmitTicketEvent event, Emitter<TicketState> emit) async {
yield TicketLoading(); emit(TicketLoading());
try { try {
// final List<HelpCategory> categoryList = // final List<HelpCategory> categoryList =
// await feedbackRepository.getHelpTicketCategories(); // await feedbackRepository.getHelpTicketCategories();
// yield TicketCategoryState(categoryList); // emit(TicketCategoryState(categoryList);
} catch (error) { } catch (error) {
print(error); print(error);
yield TicketLoadError(); emit(TicketLoadError());
} }
} }
Stream<TicketState> _mapUploadImageToState(UploadImageEvent event) async* { void _mapUploadImageToState(UploadImageEvent event, Emitter<TicketState> emit) async {
yield TicketLoading(); emit(TicketLoading());
try { try {
final String url = await feedbackRepository.upload(event.filePath); final String url = await feedbackRepository.upload(event.filePath);
yield UploadImageSuccess(url); emit(UploadImageSuccess(url));
} catch (error) { } catch (error) {
print(error); print(error);
yield UpLoadImageError(); emit(UpLoadImageError());
} }
} }
} }

@ -54,28 +54,23 @@ class BytedeskKefu {
static void initWithUsernameAndNicknameAndAvatar(String username, static void initWithUsernameAndNicknameAndAvatar(String username,
String nickname, String avatar, String appKey, String subDomain) async { String nickname, String avatar, String appKey, String subDomain) async {
// anonymousLogin(appKey, subDomain);
/// sp /// sp
await SpUtil.getInstance(); await SpUtil.getInstance();
// //
String? spusername = SpUtil.getString(BytedeskConstants.username); String? spusername = SpUtil.getString(BytedeskConstants.username);
if (spusername!.isEmpty) { String? sppassword = SpUtil.getString(BytedeskConstants.password);
// , if (spusername!.isNotEmpty) {
//
userLogin(spusername, sppassword!, appKey, subDomain);
} else {
//
//
String password = username; String password = username;
await BytedeskUserHttpApi() await BytedeskUserHttpApi()
.registerUser(username, nickname, password, avatar, subDomain); .registerUser(username, nickname, password, avatar, subDomain);
username = username + "@" + subDomain; //
userLogin(username, password, appKey, subDomain); String usernameCompose = username + "@" + subDomain;
} else if (spusername == username) { userLogin(usernameCompose, password, appKey, subDomain);
//
String password = username;
username = username + "@" + subDomain;
userLogin(username, password, appKey, subDomain);
} else {
// TODO: ,
// String password = username;
// username = username + "@" + subDomain;
// userLogin(username, password, appKey, subDomain);
} }
} }
@ -128,7 +123,7 @@ class BytedeskKefu {
} }
await BytedeskUserHttpApi().oauth(username, password); await BytedeskUserHttpApi().oauth(username, password);
// //
BytedeskUtils.mqttConnect(); connect();
// if (role == BytedeskConstants.ROLE_ADMIN) { // if (role == BytedeskConstants.ROLE_ADMIN) {
// // TODO: // // TODO:
// } // }
@ -141,7 +136,7 @@ class BytedeskKefu {
// //
await BytedeskUserHttpApi().unionIdOAuth(unionid); await BytedeskUserHttpApi().unionIdOAuth(unionid);
// //
BytedeskUtils.mqttConnect(); connect();
// //
await BytedeskDeviceHttpApi().setDeviceInfo(); await BytedeskDeviceHttpApi().setDeviceInfo();
} }
@ -149,7 +144,7 @@ class BytedeskKefu {
// //
static void otherOAuth() async { static void otherOAuth() async {
// //
BytedeskUtils.mqttConnect(); connect();
// //
await BytedeskDeviceHttpApi().setDeviceInfo(); await BytedeskDeviceHttpApi().setDeviceInfo();
} }
@ -164,6 +159,11 @@ class BytedeskKefu {
return BytedeskUtils.mqttReConnect(); return BytedeskUtils.mqttReConnect();
} }
//
static void disconnect() {
BytedeskUtils.mqttDisconnect();
}
// //
static bool isConnected() { static bool isConnected() {
return BytedeskUtils.isMqttConnected(); return BytedeskUtils.isMqttConnected();
@ -489,6 +489,9 @@ class BytedeskKefu {
// 退 // 退
static Future<void> logout() { static Future<void> logout() {
//
disconnect();
//
return BytedeskUserHttpApi().logout(); return BytedeskUserHttpApi().logout();
} }

@ -17,7 +17,6 @@ import 'package:http/http.dart' as http;
class BytedeskUserHttpApi extends BytedeskBaseHttpApi { class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
// //
Future<OAuth> oauth(String? username, String? password) async { Future<OAuth> oauth(String? username, String? password) async {
// final oauthUrl = '$baseUrl/oauth/token';
var oauthUrl = Uri.http(BytedeskConstants.host, '/oauth/token'); var oauthUrl = Uri.http(BytedeskConstants.host, '/oauth/token');
// print("http api client: oauthUrl $oauthUrl"); // print("http api client: oauthUrl $oauthUrl");
Map<String, String> headers = { Map<String, String> headers = {
@ -31,12 +30,13 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
}; };
final oauthResponse = final oauthResponse =
await this.httpClient.post(oauthUrl, headers: headers, body: bodyMap); await this.httpClient.post(oauthUrl, headers: headers, body: bodyMap);
// print('oauth result: $oauthResponse'); print('oauth result: $oauthResponse');
// check the status code for the result // check the status code for the result
int statusCode = oauthResponse.statusCode; int statusCode = oauthResponse.statusCode;
// print("statusCode $statusCode"); // print("statusCode $statusCode");
// 200: // 200:
final oauthJson = jsonDecode(oauthResponse.body); final oauthJson = jsonDecode(oauthResponse.body);
// print('oauthJson:' + oauthJson);
SpUtil.putBool(BytedeskConstants.isLogin, true); SpUtil.putBool(BytedeskConstants.isLogin, true);
SpUtil.putString(BytedeskConstants.accessToken, oauthJson['access_token']); SpUtil.putString(BytedeskConstants.accessToken, oauthJson['access_token']);
// //
@ -187,28 +187,35 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
Uri.http(BytedeskConstants.host, '/visitor/api/register/user'); Uri.http(BytedeskConstants.host, '/visitor/api/register/user');
final initResponse = final initResponse =
await this.httpClient.post(initUrl, headers: headers, body: body); await this.httpClient.post(initUrl, headers: headers, body: body);
//json //json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json //string json
final responseJson = final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes)); json.decode(utf8decoder.convert(initResponse.bodyBytes));
// final responseJson = json.decode(initResponse.body);
print("responseJson $responseJson"); print("responseJson $responseJson");
// return JsonResult.fromJson(responseJson); //
int statusCode = responseJson['status_code']; int statusCode = responseJson['status_code'];
if (statusCode == 200) { if (statusCode == 200) {
//
User user = User.fromJson(responseJson['data']); User user = User.fromJson(responseJson['data']);
// //
SpUtil.putString(BytedeskConstants.uid, user.uid!); SpUtil.putString(BytedeskConstants.uid, user.uid!);
SpUtil.putString(BytedeskConstants.username, user.username!); SpUtil.putString(BytedeskConstants.username, user.username!);
SpUtil.putString(BytedeskConstants.password, password!);
SpUtil.putString(BytedeskConstants.nickname, user.nickname!); SpUtil.putString(BytedeskConstants.nickname, user.nickname!);
SpUtil.putString(BytedeskConstants.avatar, user.avatar!); SpUtil.putString(BytedeskConstants.avatar, user.avatar!);
SpUtil.putString(BytedeskConstants.description, user.description!); SpUtil.putString(BytedeskConstants.description, user.description!);
SpUtil.putString(BytedeskConstants.subDomain, user.subDomain!); SpUtil.putString(BytedeskConstants.subDomain, user.subDomain!);
// //
return user; return user;
} else {
//
SpUtil.putString(BytedeskConstants.uid, responseJson['data']);
SpUtil.putString(BytedeskConstants.username, username! + '@' + subDomain!);
SpUtil.putString(BytedeskConstants.password, password!);
SpUtil.putString(BytedeskConstants.nickname, nickname!);
SpUtil.putString(BytedeskConstants.avatar, avatar!);
SpUtil.putString(BytedeskConstants.description, "");
SpUtil.putString(BytedeskConstants.subDomain, subDomain);
} }
return new User(); return new User();
} }
@ -240,9 +247,6 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
Future<CodeResult> requestCode(String? mobile) async { Future<CodeResult> requestCode(String? mobile) async {
// //
Map<String, String> headers = {"Content-Type": "application/json"}; Map<String, String> headers = {"Content-Type": "application/json"};
//
// final initUrl =
// '$baseUrl/sms/api/send/liangshibao?mobile=$mobile&client=$client';
final initUrl = Uri.http(BytedeskConstants.host, final initUrl = Uri.http(BytedeskConstants.host,
'/sms/api/send/liangshibao', {'mobile': mobile, 'client': client}); '/sms/api/send/liangshibao', {'mobile': mobile, 'client': client});
final initResponse = await this.httpClient.get(initUrl, headers: headers); final initResponse = await this.httpClient.get(initUrl, headers: headers);
@ -263,10 +267,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
Future<JsonResult> bindMobile(String? mobile) async { Future<JsonResult> bindMobile(String? mobile) async {
// //
String? uid = SpUtil.getString(BytedeskConstants.uid); String? uid = SpUtil.getString(BytedeskConstants.uid);
//
var body = json.encode({"uid": uid, "mobile": mobile, "client": client}); var body = json.encode({"uid": uid, "mobile": mobile, "client": client});
// //
// final initUrl = '$baseUrl/api/user/bind/mobile';
final initUrl = Uri.http(BytedeskConstants.host, '/api/user/bind/mobile'); final initUrl = Uri.http(BytedeskConstants.host, '/api/user/bind/mobile');
final initResponse = final initResponse =
await this.httpClient.post(initUrl, headers: getHeaders(), body: body); await this.httpClient.post(initUrl, headers: getHeaders(), body: body);
@ -288,7 +290,6 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
/// ///
Future<User> getProfile() async { Future<User> getProfile() async {
// //
// final initUrl = '$baseUrl/api/user/profile?client=$client';
final initUrl = Uri.http( final initUrl = Uri.http(
BytedeskConstants.host, '/api/user/profile/simple', {'client': client}); BytedeskConstants.host, '/api/user/profile/simple', {'client': client});
final initResponse = final initResponse =
@ -317,8 +318,6 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
Future<User> updateNickname(String? nickname) async { Future<User> updateNickname(String? nickname) async {
// //
var body = json.encode({"nickname": nickname, "client": client}); var body = json.encode({"nickname": nickname, "client": client});
//
// final initUrl = '$baseUrl/api/user/nickname';
final initUrl = Uri.http(BytedeskConstants.host, '/api/user/nickname'); final initUrl = Uri.http(BytedeskConstants.host, '/api/user/nickname');
final initResponse = final initResponse =
await this.httpClient.post(initUrl, headers: getHeaders(), body: body); await this.httpClient.post(initUrl, headers: getHeaders(), body: body);
@ -774,8 +773,6 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
Map<String, String> headers = {"Content-Type": "application/json"}; Map<String, String> headers = {"Content-Type": "application/json"};
var body = json.encode({"client": client}); var body = json.encode({"client": client});
// final initUrl = '$baseUrl/api/user/logout?access_token=$accessToken';
final initUrl = Uri.http(BytedeskConstants.host, '/api/user/logout', final initUrl = Uri.http(BytedeskConstants.host, '/api/user/logout',
{'access_token': accessToken}); {'access_token': accessToken});
final initResponse = final initResponse =
@ -784,23 +781,6 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
final responseJson = json.decode(initResponse.body); final responseJson = json.decode(initResponse.body);
print("responseJson $responseJson"); print("responseJson $responseJson");
// //
// Preference.clearAccessToken();
BytedeskUtils.clearUserCache(); BytedeskUtils.clearUserCache();
//
// SpUtil.putString(BytedeskConstants.uid, '');
// SpUtil.putString(BytedeskConstants.username, '');
// SpUtil.putString(BytedeskConstants.nickname, '');
// SpUtil.putString(BytedeskConstants.avatar, '');
// SpUtil.putString(BytedeskConstants.description, '');
// SpUtil.putString(BytedeskConstants.subDomain, '');
// SpUtil.putString(BytedeskConstants.role, '');
// //
// SpUtil.putString(BytedeskConstants.unionid, '');
// SpUtil.putString(BytedeskConstants.openid, '');
// //
// SpUtil.putBool(BytedeskConstants.isLogin, false);
// SpUtil.putBool(BytedeskConstants.isAuthenticated, false);
// SpUtil.putString(BytedeskConstants.mobile, '');
// SpUtil.putString(BytedeskConstants.accessToken, '');
} }
} }

@ -67,7 +67,7 @@ class MessageProvider {
version: 9, version: 9,
); );
// database path:/Users/ningjinpeng/Library/Developer/CoreSimulator/Devices/715CBA02-A602-4DE1-8C57-75A64B53BF03/data/Containers/Data/Application/8F46273D-9492-4C42-A618-4DF3815562BA/Documents/bytedesk-message-v9.db // database path:/Users/ningjinpeng/Library/Developer/CoreSimulator/Devices/715CBA02-A602-4DE1-8C57-75A64B53BF03/data/Containers/Data/Application/8F46273D-9492-4C42-A618-4DF3815562BA/Documents/bytedesk-message-v9.db
// print('database path:' + database!.path); print('database path:' + database!.path);
} }
Future<int> insert(Message message) async { Future<int> insert(Message message) async {

@ -24,7 +24,7 @@ import 'package:bytedesk_kefu/protobuf/thread.pb.dart' as protothread;
// ignore: import_of_legacy_library_into_null_safe // ignore: import_of_legacy_library_into_null_safe
import 'package:bytedesk_kefu/protobuf/user.pb.dart' as protouser; import 'package:bytedesk_kefu/protobuf/user.pb.dart' as protouser;
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart'; // import 'package:fluttertoast/fluttertoast.dart';
// import 'package:vibration/vibration.dart'; // import 'package:vibration/vibration.dart';
class BytedeskMqtt { class BytedeskMqtt {
@ -46,13 +46,13 @@ class BytedeskMqtt {
return _singleton; return _singleton;
} }
BytedeskMqtt._internal() { BytedeskMqtt._internal() {
_connect(); // _connect();
}
//
void _connect() async {
//
reconnect(); reconnect();
} }
//
// void _connect() async {
// reconnect();
// }
void reconnect() async { void reconnect() async {
// eventbus广... // eventbus广...
@ -60,8 +60,6 @@ class BytedeskMqtt {
.fire(ConnectionEventBus(BytedeskConstants.USER_STATUS_CONNECTING)); .fire(ConnectionEventBus(BytedeskConstants.USER_STATUS_CONNECTING));
// //
currentUid = SpUtil.getString(BytedeskConstants.uid); currentUid = SpUtil.getString(BytedeskConstants.uid);
// String role = SpUtil.getString(BytedeskConstants.role,
// defValue: BytedeskConstants.ROLE_VISITOR);
client = BytedeskUtils.getClient(); client = BytedeskUtils.getClient();
clientId = "$currentUid/$client"; clientId = "$currentUid/$client";
@ -81,6 +79,11 @@ class BytedeskMqtt {
MqttServerClient(BytedeskConstants.webSocketWssUrl, clientId!); MqttServerClient(BytedeskConstants.webSocketWssUrl, clientId!);
mqttClient.useWebSocket = true; mqttClient.useWebSocket = true;
mqttClient.port = 443; mqttClient.port = 443;
/// You can also supply your own websocket protocol list or disable this feature using the websocketProtocols
/// setter, read the API docs for further details here, the vast majority of brokers will support the client default
/// list so in most cases you can ignore this. Mosquito needs the single default setting.
// mqttClient.websocketProtocols = MqttClientConstants.protocolsSingleDefault;
} else { } else {
mqttClient = MqttServerClient(BytedeskConstants.mqttHost, clientId!); mqttClient = MqttServerClient(BytedeskConstants.mqttHost, clientId!);
mqttClient.port = BytedeskConstants.mqttPort; mqttClient.port = BytedeskConstants.mqttPort;
@ -92,6 +95,7 @@ class BytedeskMqtt {
mqttClient.setProtocolV311(); mqttClient.setProtocolV311();
/// Set logging on if needed, defaults to off /// Set logging on if needed, defaults to off
// mqttClient.logging(on: BytedeskConstants.isDebug);
mqttClient.logging(on: false); // BytedeskConstants.isDebug mqttClient.logging(on: false); // BytedeskConstants.isDebug
/// If you intend to use a keep alive value in your connect message that is not the default(60s) /// If you intend to use a keep alive value in your connect message that is not the default(60s)
/// you must set it here /// you must set it here
@ -111,7 +115,7 @@ class BytedeskMqtt {
/// client identifier, any supplied username/password, the default keepalive interval(60s) /// client identifier, any supplied username/password, the default keepalive interval(60s)
/// and clean session, an example of a specific one below. /// and clean session, an example of a specific one below.
final MqttConnectMessage connMess = MqttConnectMessage() final MqttConnectMessage connMessage = MqttConnectMessage()
.withClientIdentifier(clientId!) .withClientIdentifier(clientId!)
.authenticateAs('username', 'password'); // TODO: auth便 .authenticateAs('username', 'password'); // TODO: auth便
// .keepAliveFor(keepAlivePeriod); // Must agree with the keep alive set above or not set // .keepAliveFor(keepAlivePeriod); // Must agree with the keep alive set above or not set
@ -123,7 +127,7 @@ class BytedeskMqtt {
if (BytedeskConstants.isDebug) { if (BytedeskConstants.isDebug) {
print('mqttClient connecting....'); print('mqttClient connecting....');
} }
mqttClient.connectionMessage = connMess; mqttClient.connectionMessage = connMessage;
/// Connect the client, any errors here are communicated by raising of the appropriate exception. Note /// Connect the client, any errors here are communicated by raising of the appropriate exception. Note
/// in some circumstances the broker will just disconnect us, see the spec about this, we however eill /// in some circumstances the broker will just disconnect us, see the spec about this, we however eill
@ -162,7 +166,7 @@ class BytedeskMqtt {
// print('Published notification:: topic is ${messageBinary.variableHeader.topicName}, with Qos ${messageBinary.header.qos}'); // print('Published notification:: topic is ${messageBinary.variableHeader.topicName}, with Qos ${messageBinary.header.qos}');
// //
protomsg.Message messageProto = protomsg.Message messageProto =
protomsg.Message.fromBuffer(messageBinary.payload.message!); protomsg.Message.fromBuffer(messageBinary.payload.message);
// FIXME: mid // FIXME: mid
var mid = messageProto.mid; var mid = messageProto.mid;
if (midList.contains(mid)) { if (midList.contains(mid)) {
@ -220,7 +224,8 @@ class BytedeskMqtt {
isSend: uid == currentUid ? 1 : 0, isSend: uid == currentUid ? 1 : 0,
currentUid: currentUid, currentUid: currentUid,
thread: thread, thread: thread,
user: user); user: user,
client: client);
// //
// var autoReply = false; // var autoReply = false;
var sendReceipt = false; var sendReceipt = false;
@ -282,10 +287,15 @@ class BytedeskMqtt {
message.content = messageProto.text.content; message.content = messageProto.text.content;
break; break;
} }
case BytedeskConstants.MESSAGE_TYPE_NOTIFICATION_QUEUE:
{
message.content = messageProto.text.content;
break;
}
case BytedeskConstants.MESSAGE_TYPE_NOTIFICATION_QUEUE_ACCEPT: case BytedeskConstants.MESSAGE_TYPE_NOTIFICATION_QUEUE_ACCEPT:
{ {
// 'joinQueueThread' // 'joinQueueThread'
message.content = '接入队列会话'; message.content = '接入队列会话'; // TODO:
break; break;
} }
case BytedeskConstants.MESSAGE_TYPE_NOTIFICATION_AGENT_CLOSE: case BytedeskConstants.MESSAGE_TYPE_NOTIFICATION_AGENT_CLOSE:
@ -667,8 +677,7 @@ class BytedeskMqtt {
currentThread, extraParam); currentThread, extraParam);
} }
void publish(String content, String type, Thread currentThread, void publish(String content, String type, Thread currentThread, ExtraParam? extraParam) {
ExtraParam? extraParam) {
// if (currentThread == null) { // if (currentThread == null) {
// print('连接客服失败,请退出页面重新进入。注意: 请在App启动的时候调用init接口'); // print('连接客服失败,请退出页面重新进入。注意: 请在App启动的时候调用init接口');
// Fluttertoast.showToast(msg: '连接客服失败,请退出页面重新进入'); // Fluttertoast.showToast(msg: '连接客服失败,请退出页面重新进入');
@ -699,7 +708,7 @@ class BytedeskMqtt {
user.avatar = SpUtil.getString(BytedeskConstants.avatar)!; user.avatar = SpUtil.getString(BytedeskConstants.avatar)!;
// msg // msg
protomsg.Message messageProto = new protomsg.Message(); protomsg.Message messageProto = new protomsg.Message();
messageProto.mid = BytedeskUuid.generateV4(); messageProto.mid = BytedeskUuid.uuid();
messageProto.type = type; messageProto.type = type;
messageProto.timestamp = BytedeskUtils.formatedDateNow(); messageProto.timestamp = BytedeskUtils.formatedDateNow();
messageProto.client = BytedeskUtils.getClient(); //BytedeskConstants.client; messageProto.client = BytedeskUtils.getClient(); //BytedeskConstants.client;
@ -710,7 +719,7 @@ class BytedeskMqtt {
message.mid = messageProto.mid; message.mid = messageProto.mid;
message.type = messageProto.type; message.type = messageProto.type;
message.timestamp = messageProto.timestamp; message.timestamp = messageProto.timestamp;
// message.client message.client = messageProto.client;
message.nickname = user.nickname; message.nickname = user.nickname;
message.avatar = user.avatar; message.avatar = user.avatar;
message.topic = thread.topic; message.topic = thread.topic;

@ -52,8 +52,8 @@ class MqttBrowserWsConnection extends MqttBrowserConnection {
client = WebSocket(uriString, protocols); client = WebSocket(uriString, protocols);
client.binaryType = 'arraybuffer'; client.binaryType = 'arraybuffer';
messageStream = MqttByteBuffer(typed.Uint8Buffer()); messageStream = MqttByteBuffer(typed.Uint8Buffer());
var closeEvents; dynamic closeEvents;
var errorEvents; dynamic errorEvents;
client.onOpen.listen((e) { client.onOpen.listen((e) {
MqttLogger.log('MqttBrowserWsConnection::connect - websocket is open'); MqttLogger.log('MqttBrowserWsConnection::connect - websocket is open');
closeEvents.cancel(); closeEvents.cancel();
@ -117,8 +117,8 @@ class MqttBrowserWsConnection extends MqttBrowserConnection {
client = WebSocket(uriString, protocols); client = WebSocket(uriString, protocols);
client.binaryType = 'arraybuffer'; client.binaryType = 'arraybuffer';
messageStream = MqttByteBuffer(typed.Uint8Buffer()); messageStream = MqttByteBuffer(typed.Uint8Buffer());
var closeEvents; dynamic closeEvents;
var errorEvents; dynamic errorEvents;
client.onOpen.listen((e) { client.onOpen.listen((e) {
MqttLogger.log( MqttLogger.log(
'MqttBrowserWsConnection::connectAuto - websocket is open'); 'MqttBrowserWsConnection::connectAuto - websocket is open');
@ -181,4 +181,13 @@ class MqttBrowserWsConnection extends MqttBrowserConnection {
client = null; client = null;
} }
} }
/// Stops listening and closes the socket immediately.
@override
void stopListening() {
if (client != null) {
listener?.cancel();
client.close();
}
}
} }

@ -49,6 +49,9 @@ abstract class IMqttConnectionHandler {
/// Closes a connection. /// Closes a connection.
void close(); void close();
/// Kills all listeners from old connections.
void stopListening();
/// Connects to a message broker /// Connects to a message broker
/// The broker server to connect to /// The broker server to connect to
/// The port to connect to /// The port to connect to

@ -21,6 +21,10 @@ class MqttConnectionBase {
@protected @protected
dynamic client; dynamic client;
/// The stream controller as returned when clients listen.
@protected
StreamSubscription? listener;
/// The read wrapper /// The read wrapper
@protected @protected
ReadWrapper? readWrapper; ReadWrapper? readWrapper;
@ -75,12 +79,17 @@ class MqttConnectionBase {
void _disconnect() { void _disconnect() {
if (client != null) { if (client != null) {
client.close(); listener?.cancel();
client.destroy(); client.destroy();
client.close();
client = null; client = null;
} }
} }
/// Stops listening and closes the socket immediately, must be overridden in
/// connection classes
void stopListening() {}
/// User requested or auto disconnect disconnection /// User requested or auto disconnect disconnection
@protected @protected
void disconnect({bool auto = false}) { void disconnect({bool auto = false}) {

@ -184,6 +184,11 @@ abstract class MqttConnectionHandlerBase implements IMqttConnectionHandler {
} }
} }
@override
void stopListening() {
connection.stopListening();
}
/// Registers for the receipt of messages when they arrive. /// Registers for the receipt of messages when they arrive.
@override @override
void registerForMessage( void registerForMessage(

@ -16,11 +16,16 @@ typedef PongCallback = void Function();
/// This class implements the keep alive by sending an MqttPingRequest /// This class implements the keep alive by sending an MqttPingRequest
/// to the broker if a message has not been sent or received /// to the broker if a message has not been sent or received
/// within the keep alive period. /// within the keep alive period.
/// Optionally a disconnect on no response property can be set to force disconnect the client
/// if the broker does not respond to a ping request for a specified period of time.
class MqttConnectionKeepAlive { class MqttConnectionKeepAlive {
/// Initializes a new instance of the MqttConnectionKeepAlive class. /// Initializes a new instance of the MqttConnectionKeepAlive class.
MqttConnectionKeepAlive( MqttConnectionKeepAlive(IMqttConnectionHandler connectionHandler,
IMqttConnectionHandler connectionHandler, int keepAliveSeconds) { events.EventBus? eventBus, int keepAliveSeconds,
[int disconnectOnNoResponsePeriod = 0]) {
_connectionHandler = connectionHandler; _connectionHandler = connectionHandler;
_clientEventBus = eventBus;
this.disconnectOnNoResponsePeriod = disconnectOnNoResponsePeriod * 1000;
keepAlivePeriod = keepAliveSeconds * 1000; keepAlivePeriod = keepAliveSeconds * 1000;
// Register for message handling of ping request and response messages. // Register for message handling of ping request and response messages.
connectionHandler.registerForMessage( connectionHandler.registerForMessage(
@ -31,15 +36,28 @@ class MqttConnectionKeepAlive {
// Start the timer so we do a ping whenever required. // Start the timer so we do a ping whenever required.
pingTimer = Timer(Duration(milliseconds: keepAlivePeriod), pingRequired); pingTimer = Timer(Duration(milliseconds: keepAlivePeriod), pingRequired);
MqttLogger.log( MqttLogger.log(
'MqttConnectionKeepAlive:: initialised with a keep alive value of $keepAliveSeconds seconds'); 'MqttConnectionKeepAlive:: Initialised with a keep alive value of $keepAliveSeconds seconds');
disconnectOnNoResponsePeriod == 0
? MqttLogger.log(
'MqttConnectionKeepAlive:: Disconnect on no ping response is disabled')
: MqttLogger.log(
'MqttConnectionKeepAlive:: Disconnect on no ping response is enabled with a value of $disconnectOnNoResponsePeriod seconds');
} }
/// The keep alive period in milliseconds /// The keep alive period in milliseconds
late int keepAlivePeriod; late int keepAlivePeriod;
/// The period of time to wait if the broker does not respond to a ping request, in milliseconds.
/// If this time period is exceeded the client is forcibly disconnected.
/// The default is 0, which disables this functionality.
int disconnectOnNoResponsePeriod = 0;
/// The timer that manages the ping callbacks. /// The timer that manages the ping callbacks.
Timer? pingTimer; Timer? pingTimer;
/// Timer that manages the disconnect on no ping response period.
Timer? disconnectTimer;
/// The connection handler /// The connection handler
late IMqttConnectionHandler _connectionHandler; late IMqttConnectionHandler _connectionHandler;
@ -49,6 +67,9 @@ class MqttConnectionKeepAlive {
/// Ping response received callback /// Ping response received callback
PongCallback? pongCallback; PongCallback? pongCallback;
/// The event bus
events.EventBus? _clientEventBus;
/// Pings the message broker if there has been no activity for /// Pings the message broker if there has been no activity for
/// the specified amount of idle time. /// the specified amount of idle time.
bool pingRequired() { bool pingRequired() {
@ -73,6 +94,30 @@ class MqttConnectionKeepAlive {
MqttLogger.log( MqttLogger.log(
'MqttConnectionKeepAlive::pingRequired - restarting ping timer'); 'MqttConnectionKeepAlive::pingRequired - restarting ping timer');
pingTimer = Timer(Duration(milliseconds: keepAlivePeriod), pingRequired); pingTimer = Timer(Duration(milliseconds: keepAlivePeriod), pingRequired);
if (disconnectOnNoResponsePeriod != 0) {
if (disconnectTimer == null) {
MqttLogger.log(
'MqttConnectionKeepAlive::pingRequired - starting disconnect timer');
if (pinged) {
disconnectTimer = Timer(
Duration(milliseconds: disconnectOnNoResponsePeriod),
noPingResponseReceived);
}
} else {
if (disconnectTimer != null && !disconnectTimer!.isActive) {
if (pinged) {
MqttLogger.log(
'MqttConnectionKeepAlive::pingRequired - restarting disconnect timer');
disconnectTimer = Timer(
Duration(milliseconds: disconnectOnNoResponsePeriod),
noPingResponseReceived);
}
} else {
MqttLogger.log(
'MqttConnectionKeepAlive::pingRequired - disconnect timer is active, not restarting');
}
}
}
_shutdownPadlock = false; _shutdownPadlock = false;
return pinged; return pinged;
} }
@ -101,6 +146,8 @@ class MqttConnectionKeepAlive {
if (pongCallback != null) { if (pongCallback != null) {
pongCallback!(); pongCallback!();
} }
// Cancel the disconnect timer if needed.
disconnectTimer?.cancel();
return true; return true;
} }
@ -111,5 +158,27 @@ class MqttConnectionKeepAlive {
void stop() { void stop() {
MqttLogger.log('MqttConnectionKeepAlive::stop - stopping keep alive'); MqttLogger.log('MqttConnectionKeepAlive::stop - stopping keep alive');
pingTimer!.cancel(); pingTimer!.cancel();
disconnectTimer?.cancel();
}
/// Handle the disconnect timer timeout
void noPingResponseReceived() {
// Only disconnect if we are connected.
if (_connectionHandler.connectionStatus.state ==
MqttConnectionState.connected) {
MqttLogger.log(
'MqttConnectionKeepAlive::noPingResponseReceived - connected, attempting to disconnect');
if (_clientEventBus != null) {
_clientEventBus!.fire(DisconnectOnNoPingResponse());
MqttLogger.log(
'MqttConnectionKeepAlive::noPingResponseReceived - OK - disconnect event fired');
} else {
MqttLogger.log(
'MqttConnectionKeepAlive::noPingResponseReceived - ERROR - disconnect event not fired, no event handler');
}
} else {
MqttLogger.log(
'MqttConnectionKeepAlive::noPingResponseReceived - not disconnecting, not connected');
}
} }
} }

@ -36,7 +36,7 @@ class MqttServerConnection extends MqttConnectionBase {
void _startListening() { void _startListening() {
MqttLogger.log('MqttServerConnection::_startListening'); MqttLogger.log('MqttServerConnection::_startListening');
try { try {
client.listen(_onData, onError: onError, onDone: onDone); listener = client.listen(_onData, onError: onError, onDone: onDone);
} on Exception catch (e) { } on Exception catch (e) {
print('MqttServerConnection::_startListening - exception raised $e'); print('MqttServerConnection::_startListening - exception raised $e');
} }
@ -94,4 +94,14 @@ class MqttServerConnection extends MqttConnectionBase {
final messageBytes = message.read(message.length); final messageBytes = message.read(message.length);
client?.add(messageBytes.toList()); client?.add(messageBytes.toList());
} }
/// Stops listening and closes the socket immediately.
@override
void stopListening() {
if (client != null) {
listener?.cancel();
client.destroy();
client.close();
}
}
} }

@ -151,7 +151,8 @@ class MqttServerWs2Connection extends MqttServerConnection {
messageStream = MqttByteBuffer(typed.Uint8Buffer()); messageStream = MqttByteBuffer(typed.Uint8Buffer());
MqttLogger.log('MqttWs2Connection::connect - start listening'); MqttLogger.log('MqttWs2Connection::connect - start listening');
_startListening(); _startListening();
completer.complete(); completer.complete(MqttClientConnectionStatus()
..state = MqttConnectionState.connected);
}).catchError((dynamic e) { }).catchError((dynamic e) {
onError(e); onError(e);
completer.completeError(e); completer.completeError(e);
@ -242,6 +243,15 @@ class MqttServerWs2Connection extends MqttServerConnection {
return completer.future; return completer.future;
} }
/// Stops listening and closes the socket immediately.
@override
void stopListening() {
if (client != null) {
listener?.cancel();
client.close();
}
}
Future<bool> _performWSHandshake(Socket socket, Uri uri) async { Future<bool> _performWSHandshake(Socket socket, Uri uri) async {
_response = ''; _response = '';
final c = Completer<bool>(); final c = Completer<bool>();

@ -146,4 +146,13 @@ class MqttServerWsConnection extends MqttServerConnection {
client = null; client = null;
} }
} }
/// Stops listening and closes the socket immediately.
@override
void stopListening() {
if (client != null) {
listener?.cancel();
client.close();
}
}
} }

@ -20,7 +20,7 @@ class MqttClientTopicFilter {
_subscriptionTopic = SubscriptionTopic(_topic); _subscriptionTopic = SubscriptionTopic(_topic);
_clientUpdates!.listen(_topicIn); _clientUpdates!.listen(_topicIn);
_updates = _updates =
StreamController<List<MqttReceivedMessage<MqttMessage>>>.broadcast( StreamController<List<MqttReceivedMessage<MqttMessage?>>>.broadcast(
sync: true); sync: true);
} }

@ -58,7 +58,7 @@ class MqttPublishMessage extends MqttMessage {
/// Appends data to publish to the end of the current message payload. /// Appends data to publish to the end of the current message payload.
MqttPublishMessage publishData(typed.Uint8Buffer data) { MqttPublishMessage publishData(typed.Uint8Buffer data) {
payload.message!.addAll(data); payload.message.addAll(data);
return this; return this;
} }
@ -76,7 +76,7 @@ class MqttPublishMessage extends MqttMessage {
/// Removes the current published data. /// Removes the current published data.
MqttPublishMessage clearPublishData() { MqttPublishMessage clearPublishData() {
payload.message!.clear(); payload.message.clear();
return this; return this;
} }

@ -27,7 +27,7 @@ class MqttPublishPayload extends MqttPayload {
MqttPublishVariableHeader? variableHeader; MqttPublishVariableHeader? variableHeader;
/// The message that forms the payload of the publish message. /// The message that forms the payload of the publish message.
typed.Uint8Buffer? message; late typed.Uint8Buffer message;
/// Creates a payload from the specified header stream. /// Creates a payload from the specified header stream.
@override @override
@ -48,11 +48,11 @@ class MqttPublishPayload extends MqttPayload {
/// Gets the length of the payload in bytes when written to a stream. /// Gets the length of the payload in bytes when written to a stream.
@override @override
int getWriteLength() => message!.length; int getWriteLength() => message.length;
@override @override
String toString() => String toString() =>
'Payload: {${message!.length} bytes={${bytesToString(message!)}'; 'Payload: {${message.length} bytes={${bytesToString(message)}';
/// Converts an array of bytes to a byte string. /// Converts an array of bytes to a byte string.
static String bytesToString(typed.Uint8Buffer message) { static String bytesToString(typed.Uint8Buffer message) {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save