Commit e4443f6f by 徐利超

update 暂存版本1

parent cf5e9be6
...@@ -10,12 +10,21 @@ ...@@ -10,12 +10,21 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@protocol YUNXINDemoViewDelegate <NSObject>
- (void)demoViewDismiss;
@end
@interface YUNXINDemoView : UIView @interface YUNXINDemoView : UIView
@property (nonatomic, weak) id<YUNXINDemoViewDelegate> delegate;
@property (nonatomic, strong) NSString *requesterUid;
- (void)show; - (void)show;
- (void)dismiss; - (void)dismiss;
- (void)updateToolBarWhenSameScreenAuthorityReq; - (void)updateToolBarWhenSameScreenAuthorityReq;
- (void)updateToolBarWhenMarkAuthorityReq;
@end @end
......
...@@ -12,13 +12,15 @@ ...@@ -12,13 +12,15 @@
@interface YUNXINDemoView () @interface YUNXINDemoView ()
@property (nonatomic, strong) YUNXINSameScreenView *sameScrennView; @property (nonatomic, strong) UIView *sameScrennView;
@property (nonatomic, assign) BOOL isAnimated; @property (nonatomic, assign) BOOL isAnimated;
@property (nonatomic, strong) UIView *toolBarView; @property (nonatomic, strong) UIView *toolBarView;
@property (nonatomic, strong) UIButton *cancelBtn; @property (nonatomic, strong) UIButton *cancelBtn;
@property (nonatomic, strong) UIButton *markBtn; @property (nonatomic, strong) UIButton *markBtn;
@property (nonatomic, strong) UIButton *callBackBtn; @property (nonatomic, strong) UIButton *callBackBtn;
@property (nonatomic, strong) UIButton *clearBtn;
@property (nonatomic, strong) UIButton *undoBtn;
@property (nonatomic, assign) BOOL isMark; @property (nonatomic, assign) BOOL isMark;
...@@ -30,6 +32,7 @@ ...@@ -30,6 +32,7 @@
{ {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
self .backgroundColor = [UIColor whiteColor];
self.isAnimated = NO; self.isAnimated = NO;
[self setupUI]; [self setupUI];
} }
...@@ -39,10 +42,9 @@ ...@@ -39,10 +42,9 @@
- (void)setupUI - (void)setupUI
{ {
self.sameScrennView = [[YUNXINSameScreenManager shareInstance] getSameScreenViewWithFrame:CGRectMake(0, kStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kStatusBarHeight - 40 - kSafeButtomHeight) drawHexColor:@"#000000" isManager:YES]; self.sameScrennView = [[YUNXINSameScreenManager shareInstance] getSameScreenViewWithFrame:CGRectMake(0, kStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kStatusBarHeight - 40 - kSafeButtomHeight) drawHexColor:@"#000000" isManager:YES];
[[YUNXINSameScreenManager shareInstance] updateSameScreenViewWithWebUrl:@"http://192.168.70.182/glw/private.html" miniFlag:@"1"]; [[YUNXINSameScreenManager shareInstance] updateSameScreenViewWithWebUrl:@"http://192.168.70.182/glw/005_teamwork/private.html?v=1" miniFlag:@"1"];
[self addSubview:self.sameScrennView]; [self addSubview:self.sameScrennView];
[self addSubview:self.toolBarView]; [self addSubview:self.toolBarView];
[self updateToolBarViewWithshowArray:@[self.cancelBtn, self.markBtn]];
} }
...@@ -67,12 +69,6 @@ ...@@ -67,12 +69,6 @@
[self updateToolBarViewWithshowArray:@[self.cancelBtn, self.markBtn, self.callBackBtn]]; [self updateToolBarViewWithshowArray:@[self.cancelBtn, self.markBtn, self.callBackBtn]];
} }
- (void)updateToolBarWhenMarkAuthorityReq
{
[self.callBackBtn setTitle:@"收回标注" forState:UIControlStateNormal];
[self updateToolBarViewWithshowArray:@[self.cancelBtn, self.callBackBtn]];
}
- (void)show - (void)show
{ {
...@@ -81,6 +77,7 @@ ...@@ -81,6 +77,7 @@
} }
_isAnimated = YES; _isAnimated = YES;
_isMark = NO; _isMark = NO;
[self updateToolBarViewWithshowArray:@[self.cancelBtn, self.markBtn]];
[UIView animateWithDuration:0.2 animations:^{ [UIView animateWithDuration:0.2 animations:^{
CGRect mFrame = self.frame; CGRect mFrame = self.frame;
mFrame.origin.y -= mFrame.size.height; mFrame.origin.y -= mFrame.size.height;
...@@ -112,17 +109,20 @@ ...@@ -112,17 +109,20 @@
self.isMark = NO; self.isMark = NO;
[[YUNXINSameScreenManager shareInstance] closeMark]; [[YUNXINSameScreenManager shareInstance] closeMark];
[self.cancelBtn setTitle:@"取消同屏" forState:UIControlStateNormal]; [self.cancelBtn setTitle:@"取消同屏" forState:UIControlStateNormal];
[self updateToolBarViewWithshowArray:@[self.cancelBtn, self.markBtn]];
}else { }else {
[self dismiss]; [self dismiss];
[[YUNXINSameScreenManager shareInstance] sendDismissSameScreenViewNotification]; [[YUNXINSameScreenManager shareInstance] cancelSameScreencAction];
if ([_delegate respondsToSelector:@selector(demoViewDismiss)]) {
[_delegate demoViewDismiss];
}
} }
} }
- (void)callbackBtnTouched - (void)callbackBtnTouched
{ {
if (self.isMark) { if (!self.isMark) {
[self updateToolBarViewWithshowArray:@[self.cancelBtn]]; [[YUNXINSameScreenManager shareInstance] callbackTheRequsterSameScreenOperateAuthorityWithRequsterUid:self.requesterUid];
}else {
[self updateToolBarViewWithshowArray:@[self.cancelBtn, self.markBtn]]; [self updateToolBarViewWithshowArray:@[self.cancelBtn, self.markBtn]];
} }
} }
...@@ -132,7 +132,17 @@ ...@@ -132,7 +132,17 @@
self.isMark = YES; self.isMark = YES;
[[YUNXINSameScreenManager shareInstance] openMark]; [[YUNXINSameScreenManager shareInstance] openMark];
[self.cancelBtn setTitle:@"取消标注" forState:UIControlStateNormal]; [self.cancelBtn setTitle:@"取消标注" forState:UIControlStateNormal];
[self updateToolBarViewWithshowArray:@[self.cancelBtn]]; [self updateToolBarViewWithshowArray:@[self.cancelBtn, self.clearBtn, self.undoBtn]];
}
- (void)clearBtnTouched
{
[[YUNXINSameScreenManager shareInstance] clearCanvas];
}
- (void)undoBtnTouched
{
[[YUNXINSameScreenManager shareInstance] undoCanvas];
} }
#pragma mark - setter/getter #pragma mark - setter/getter
...@@ -140,6 +150,7 @@ ...@@ -140,6 +150,7 @@
{ {
if (!_toolBarView) { if (!_toolBarView) {
_toolBarView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - kSafeButtomHeight - 40, SCREEN_WIDTH, 40)]; _toolBarView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - kSafeButtomHeight - 40, SCREEN_WIDTH, 40)];
_toolBarView.backgroundColor = [UIColor darkGrayColor];
} }
return _toolBarView; return _toolBarView;
} }
...@@ -168,4 +179,20 @@ ...@@ -168,4 +179,20 @@
return _callBackBtn; return _callBackBtn;
} }
- (UIButton *)clearBtn
{
if (!_clearBtn) {
_clearBtn = [CHUIFactory buttonWithTitle:@"清除" font:kFont(14) titleColor:[UIColor whiteColor] target:self action:@selector(clearBtnTouched)];
}
return _clearBtn;
}
- (UIButton *)undoBtn
{
if (!_undoBtn) {
_undoBtn = [CHUIFactory buttonWithTitle:@"撤销" font:kFont(14) titleColor:[UIColor whiteColor] target:self action:@selector(undoBtnTouched)];
}
return _undoBtn;
}
@end @end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#import "CHUIFactory.h" #import "CHUIFactory.h"
#import "YUNXINSameScreenManager.h" #import "YUNXINSameScreenManager.h"
#import "YUNXINDemoView.h" #import "YUNXINDemoView.h"
@interface YUNXINDemoViewController ()<YUNXINSameScreenManagerDelegate> @interface YUNXINDemoViewController ()<YUNXINSameScreenManagerDelegate, YUNXINDemoViewDelegate>
@property (nonatomic, strong) UILabel *noticeLabel; @property (nonatomic, strong) UILabel *noticeLabel;
@property (nonatomic, strong) UIButton *hangupBtn; @property (nonatomic, strong) UIButton *hangupBtn;
...@@ -24,10 +24,13 @@ ...@@ -24,10 +24,13 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[[YUNXINSameScreenManager shareInstance] configCurrentSession:[NIMSession session:self.otherUid type:NIMSessionTypeP2P]]; [[YUNXINSameScreenManager shareInstance] configCurrentSession:[NIMSession session:self.otherUid type:NIMSessionTypeP2P]];
[[YUNXINSameScreenManager shareInstance] addDelegate:self]; [[YUNXINSameScreenManager shareInstance] addDelegate:self];
[self.view addSubview:self.noticeLabel]; [self.view addSubview:self.noticeLabel];
[self.view addSubview:self.demoView]; [self.view addSubview:self.demoView];
[self.view addSubview:self.hangupBtn];
[self.view addSubview:self.sameScreenBtn];
} }
#pragma mark - IBAction #pragma mark - IBAction
...@@ -39,7 +42,10 @@ ...@@ -39,7 +42,10 @@
- (void)sameScreenBtnTouched - (void)sameScreenBtnTouched
{ {
[_demoView show]; [_demoView show];
[[YUNXINSameScreenManager shareInstance] sendshowSameScreenViewNotification]; [[YUNXINSameScreenManager shareInstance] beginSameScreenAction];
_noticeLabel.hidden = YES;
_hangupBtn.hidden = YES;
_sameScreenBtn.hidden = YES;
} }
...@@ -47,10 +53,14 @@ ...@@ -47,10 +53,14 @@
- (void)sameScreenCloseView - (void)sameScreenCloseView
{ {
[_demoView dismiss]; [_demoView dismiss];
_noticeLabel.hidden = NO;
_hangupBtn.hidden = NO;
_sameScreenBtn.hidden = NO;
} }
- (void)sameScreenReceiveOperateReqWithUid:(NSString *)uid - (void)sameScreenReceiveOperateReqWithUid:(NSString *)uid
{ {
_demoView.requesterUid = uid;
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:[NSString stringWithFormat:@"%@请求同屏操作", uid] preferredStyle:UIAlertControllerStyleAlert]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:[NSString stringWithFormat:@"%@请求同屏操作", uid] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *approve = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { UIAlertAction *approve = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[YUNXINSameScreenManager shareInstance] approveTheSameScreenOperateAuthorityWithRequseterUid:uid isApproved:YES]; [[YUNXINSameScreenManager shareInstance] approveTheSameScreenOperateAuthorityWithRequseterUid:uid isApproved:YES];
...@@ -65,21 +75,22 @@ ...@@ -65,21 +75,22 @@
} }
- (void)sameScreenReceiveMarkOperateReqWithUid:(NSString *)uid - (void)sameScreenShowViewWithShowUrl:(NSString *)showUrl miniFlag:(NSString *)miniFlag
{ {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:[NSString stringWithFormat:@"%@请求同屏操作", uid] preferredStyle:UIAlertControllerStyleAlert]; [[YUNXINSameScreenManager shareInstance] updateSameScreenViewWithWebUrl:showUrl miniFlag:miniFlag];
UIAlertAction *approve = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [_demoView show];
[[YUNXINSameScreenManager shareInstance] approveTheSameScreenOperateAuthorityWithRequseterUid:uid isApproved:YES]; _noticeLabel.hidden = YES;
[self.demoView updateToolBarWhenMarkAuthorityReq]; _hangupBtn.hidden = YES;
}]; _sameScreenBtn.hidden = YES;
UIAlertAction *refuse = [UIAlertAction actionWithTitle:@"拒绝" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[[YUNXINSameScreenManager shareInstance] approveTheSameScreenOperateAuthorityWithRequseterUid:uid isApproved:NO];
}];
[alertController addAction:approve];
[alertController addAction:refuse];
[self presentViewController:alertController animated:YES completion:nil];
} }
#pragma mark - YUNXINDemoViewDelegate
- (void)demoViewDismiss
{
_noticeLabel.hidden = NO;
_hangupBtn.hidden = NO;
_sameScreenBtn.hidden = NO;
}
#pragma mark - setter/getter #pragma mark - setter/getter
- (UILabel *)noticeLabel - (UILabel *)noticeLabel
...@@ -102,7 +113,7 @@ ...@@ -102,7 +113,7 @@
- (UIButton *)sameScreenBtn - (UIButton *)sameScreenBtn
{ {
if (!_sameScreenBtn) { if (!_sameScreenBtn) {
_sameScreenBtn = [CHUIFactory buttonWithTitle:@"同屏" font:kFont(16) titleColor:[UIColor blueColor] target:self action:@selector(sameScreenBtnTouched) frame:CGRectMake(40, 150, 60, 30)]; _sameScreenBtn = [CHUIFactory buttonWithTitle:@"同屏" font:kFont(16) titleColor:[UIColor blueColor] target:self action:@selector(sameScreenBtnTouched) frame:CGRectMake(100, 150, 60, 30)];
} }
return _sameScreenBtn; return _sameScreenBtn;
} }
...@@ -112,6 +123,7 @@ ...@@ -112,6 +123,7 @@
{ {
if (!_demoView) { if (!_demoView) {
_demoView = [[YUNXINDemoView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT)]; _demoView = [[YUNXINDemoView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT)];
_demoView.delegate = self;
} }
return _demoView; return _demoView;
} }
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#define YUNXINSameScreenDefine_h #define YUNXINSameScreenDefine_h
#define SameScreenOpenReq @"8"
#define SameScreenOpenAnswer @"9"
#define SameScreenOperateGiveUp @"10"
#define SameScreenSyncSize @"0" #define SameScreenSyncSize @"0"
#define SameScreenOpenView @"1" #define SameScreenOpenView @"1"
#define SameScreenCloseView @"2" #define SameScreenCloseView @"2"
......
...@@ -28,6 +28,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -28,6 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)undo; - (void)undo;
- (void)updateMarkOperateStatus:(BOOL)couldMark; - (void)updateMarkOperateStatus:(BOOL)couldMark;
- (void)destoryHeartBeat;
- (void)initHeartBeat;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -81,7 +81,7 @@ dispatch_async(dispatch_get_main_queue(), block);\ ...@@ -81,7 +81,7 @@ dispatch_async(dispatch_get_main_queue(), block);\
- (void)updateViewWithWebUrl:(NSString *)webUrl miniFlag:(NSString *)miniFlag - (void)updateViewWithWebUrl:(NSString *)webUrl miniFlag:(NSString *)miniFlag
{ {
self.miniFlag = miniFlag; self.miniFlag = miniFlag;
if (webUrl.length > 0 && [webUrl isEqualToString:self.webUrl]) { if (webUrl.length > 0 && ![webUrl isEqualToString:self.webUrl]) {
self.webUrl = webUrl; self.webUrl = webUrl;
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.webUrl]]]; [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.webUrl]]];
} }
...@@ -90,8 +90,9 @@ dispatch_async(dispatch_get_main_queue(), block);\ ...@@ -90,8 +90,9 @@ dispatch_async(dispatch_get_main_queue(), block);\
- (void)updateWebViewWidth:(CGFloat)width height:(CGFloat)height - (void)updateWebViewWidth:(CGFloat)width height:(CGFloat)height
{ {
CGFloat wbWidth = width < self.viewFrame.size.width ? width : self.viewFrame.size.width; CGFloat wbWidth = width < self.viewFrame.size.width ? width : self.viewFrame.size.width;
CGFloat wbHeight = height < self.viewFrame.size.height ? height : self.viewFrame.size.width; CGFloat wbHeight = height < self.viewFrame.size.height ? height : self.viewFrame.size.height;
_webView.frame = CGRectMake((self.viewFrame.size.width - wbWidth) / 2, (self.viewFrame.size.height - wbHeight) / 2, wbWidth, wbHeight); _webView.frame = CGRectMake((self.viewFrame.size.width - wbWidth) / 2, (self.viewFrame.size.height - wbHeight) / 2, wbWidth, wbHeight);
NSLog(@"=======>>>>>> webviewSize:Width:%f Height:%f", wbWidth, wbHeight);
_scrawlView.frame = _webView.frame; _scrawlView.frame = _webView.frame;
} }
...@@ -117,6 +118,7 @@ dispatch_async(dispatch_get_main_queue(), block);\ ...@@ -117,6 +118,7 @@ dispatch_async(dispatch_get_main_queue(), block);\
- (void)updateMarkOperateStatus:(BOOL)couldMark - (void)updateMarkOperateStatus:(BOOL)couldMark
{ {
_webView.userInteractionEnabled = couldMark;
_scrawlView.userInteractionEnabled = couldMark; _scrawlView.userInteractionEnabled = couldMark;
} }
...@@ -129,6 +131,9 @@ dispatch_async(dispatch_get_main_queue(), block);\ ...@@ -129,6 +131,9 @@ dispatch_async(dispatch_get_main_queue(), block);\
_scrawlView.delegate = self; _scrawlView.delegate = self;
[self addSubview:_scrawlView]; [self addSubview:_scrawlView];
} }
if (self.isManager) {
_scrawlView.userInteractionEnabled = YES;
}
_scrawlView.hidden = NO; _scrawlView.hidden = NO;
} }
...@@ -231,7 +236,7 @@ dispatch_async(dispatch_get_main_queue(), block);\ ...@@ -231,7 +236,7 @@ dispatch_async(dispatch_get_main_queue(), block);\
webConfig.preferences.javaScriptCanOpenWindowsAutomatically = YES; webConfig.preferences.javaScriptCanOpenWindowsAutomatically = YES;
webConfig.userContentController = [WKUserContentController new]; webConfig.userContentController = [WKUserContentController new];
_webView = [[WKWebView alloc] initWithFrame:self.viewFrame configuration:webConfig]; _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, self.viewFrame.size.width, self.viewFrame.size.height) configuration:webConfig];
_webView.backgroundColor = [UIColor colorWithRed:246.0/255 green:246.0/255 blue:246.0/255 alpha:1.0]; _webView.backgroundColor = [UIColor colorWithRed:246.0/255 green:246.0/255 blue:246.0/255 alpha:1.0];
_webView.scrollView.delegate = self; _webView.scrollView.delegate = self;
_webView.UIDelegate = self; _webView.UIDelegate = self;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "YUNXINSameScreenView.h"
@class NIMSession; @class NIMSession;
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
...@@ -25,29 +25,19 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -25,29 +25,19 @@ NS_ASSUME_NONNULL_BEGIN
/// 在该回调内移除或隐藏同屏页面 /// 在该回调内移除或隐藏同屏页面
- (void)sameScreenCloseView; - (void)sameScreenCloseView;
/// 收到对方申请同屏操作的请求,只有管理员能收到该回调 /// 收到非管理员申请同屏操作的请求(管理员使用)
/// @param uid 云信account /// @param uid 云信account
- (void)sameScreenReceiveOperateReqWithUid:(NSString *)uid; - (void)sameScreenReceiveOperateReqWithUid:(NSString *)uid;
/// 收到管理员关于本方同屏操作申请的回复 /// 收到管理员关于本方同屏操作申请的回复 (非管理员使用)
/// @param isApproved 是否被同意 /// @param isApproved 是否被同意
- (void)sameScreenReceiveOperateReqResult:(BOOL)isApproved; - (void)sameScreenReceiveOperateReqResult:(BOOL)isApproved;
/// 收到管理员收回本方操作权限的通知 /// 收到管理员收回本方操作权限的通知 (非管理员使用)
- (void)sameScreenReceiveOperateCallBackNotification; - (void)sameScreenReceiveOperateCallBackNotification;
/// 收到非管理员主动放弃操作权限的通知 (管理员使用)
//标注相关 - (void)sameScreenReceiveOperateAbandonNotification;
/// 收到对方申请标注操作的请求,只有管理员 能收到该回调
/// @param uid 云信account
- (void)sameScreenReceiveMarkOperateReqWithUid:(NSString *)uid;
/// 收到管理员关于本方标注操作申请的回复
/// @param isApproved 是否被同意
- (void)sameScreenReceiveMarkOperateReqResult:(BOOL)isApproved;
/// 收到管理员收回本方标注权限的通知
- (void)sameScreenReceiveMarkOperateCallBackNotification;
@end @end
...@@ -75,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -75,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN
/// @param frame 同屏页面大小 /// @param frame 同屏页面大小
/// @param hexColorStr 标注颜色色值 默认"#000000" /// @param hexColorStr 标注颜色色值 默认"#000000"
/// @param isManager 是否是管理员 /// @param isManager 是否是管理员
- (YUNXINSameScreenView *)getSameScreenViewWithFrame:(CGRect)frame drawHexColor:(NSString *)hexColorStr isManager:(BOOL)isManager; - (UIView *)getSameScreenViewWithFrame:(CGRect)frame drawHexColor:(NSString *)hexColorStr isManager:(BOOL)isManager;
/// 更新同屏页面的内容 /// 更新同屏页面的内容
...@@ -83,14 +73,12 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -83,14 +73,12 @@ NS_ASSUME_NONNULL_BEGIN
/// @param miniFlag H5的url在小程序中对应的flag /// @param miniFlag H5的url在小程序中对应的flag
- (void)updateSameScreenViewWithWebUrl:(NSString *)webUrl miniFlag:(NSString *)miniFlag; - (void)updateSameScreenViewWithWebUrl:(NSString *)webUrl miniFlag:(NSString *)miniFlag;
/// 同步同屏页面的尺寸大小
- (void)sameScreenSynchronizeViewSize;
/// 通知manager当前已经展示同屏页面 /// 开始同屏
- (void)sendshowSameScreenViewNotification; - (void)beginSameScreenAction;
/// 通知manager当前已经移除同屏页面 /// 取消同屏
- (void)sendDismissSameScreenViewNotification; - (void)cancelSameScreencAction;
/// 请求同屏操作权限(非管理员使用) /// 请求同屏操作权限(非管理员使用)
- (void)requestForSameScreenOperateAuthority; - (void)requestForSameScreenOperateAuthority;
...@@ -100,28 +88,24 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -100,28 +88,24 @@ NS_ASSUME_NONNULL_BEGIN
/// @param isApproved 是否同意 /// @param isApproved 是否同意
- (void)approveTheSameScreenOperateAuthorityWithRequseterUid:(NSString *)requesterUid isApproved:(BOOL)isApproved; - (void)approveTheSameScreenOperateAuthorityWithRequseterUid:(NSString *)requesterUid isApproved:(BOOL)isApproved;
/// 收回请求者的操作权限 (管理员使用) /// 收回非管理员的操作权限 (管理员使用)
/// @param requesterUid 请求者云信account /// @param requesterUid 请求者云信account
- (void)callbackTheRequsterSameScreenOperateAuthorityWithRequsterUid:(NSString *)requesterUid; - (void)callbackTheRequsterSameScreenOperateAuthorityWithRequsterUid:(NSString *)requesterUid;
/// 放弃当前操作权限 (非管理员使用)
- (void)giveUpTheSameScreenOperateAuthority;
/// 打开标注 /// 打开标注
- (void)openMark; - (void)openMark;
/// 关闭标注 /// 关闭标注
- (void)closeMark; - (void)closeMark;
/// /// 请求标注操作权限(非管理员使用) /// 清除所有标记
- (void)requestForMarkOperateAuthority; - (void)clearCanvas;
/// 撤销上一步标记
/// 发送审核标注权限结果 (管理员使用) - (void)undoCanvas;
/// @param requesterUid 请求者云信account
/// @param isApproved 是否同意
- (void)approveTheMarkOperateAuthorityWithRequseterUid:(NSString *)requesterUid isApproved:(BOOL)isApproved;
/// 收回请求者标注权限 (管理员使用)
/// @param requesterUid 请求者云信account
- (void)callbackTheRequsterMarkOperateAuthorityWithRequsterUid:(NSString *)requesterUid;
/// 发送自定义通知消息 /// 发送自定义通知消息
/// @param param param /// @param param param
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "YUNXINSameScreenManager.h" #import "YUNXINSameScreenManager.h"
#import <NIMSDK/NIMSDK.h> #import <NIMSDK/NIMSDK.h>
#import "YUNXINSameScreenDefine.h" #import "YUNXINSameScreenDefine.h"
#import "YUNXINSameScreenView.h"
@interface YUNXINSameScreenManager () @interface YUNXINSameScreenManager ()
...@@ -53,8 +54,9 @@ ...@@ -53,8 +54,9 @@
_session = session; _session = session;
} }
- (YUNXINSameScreenView *)getSameScreenViewWithFrame:(CGRect)frame drawHexColor:(NSString *)hexColorStr isManager:(BOOL)isManager - (UIView *)getSameScreenViewWithFrame:(CGRect)frame drawHexColor:(NSString *)hexColorStr isManager:(BOOL)isManager
{ {
self.isManager = isManager;
self.viewSize = frame.size; self.viewSize = frame.size;
YUNXINSameScreenView *webView = [[YUNXINSameScreenView alloc] initWithFrame:frame drawHexColorStr:hexColorStr isManager:isManager]; YUNXINSameScreenView *webView = [[YUNXINSameScreenView alloc] initWithFrame:frame drawHexColorStr:hexColorStr isManager:isManager];
self.webView = webView; self.webView = webView;
...@@ -98,6 +100,8 @@ ...@@ -98,6 +100,8 @@
[self dealWithOperateAnswer:param]; [self dealWithOperateAnswer:param];
}else if ([action isEqualToString:SameScreenOperateCallback]) { }else if ([action isEqualToString:SameScreenOperateCallback]) {
[self dealWithOperateCallBack:param]; [self dealWithOperateCallBack:param];
}else if ([action isEqualToString:SameScreenOperateGiveUp]) {
}else if ([action isEqualToString:SameScreenOpenMark]) { }else if ([action isEqualToString:SameScreenOpenMark]) {
[_webView openMark]; [_webView openMark];
}else if ([action isEqualToString:SameScreenCloseMark]) { }else if ([action isEqualToString:SameScreenCloseMark]) {
...@@ -108,27 +112,23 @@ ...@@ -108,27 +112,23 @@
[_webView clearCanvas]; [_webView clearCanvas];
}else if ([action isEqualToString:SameScreenUndoPreviousPath]) { }else if ([action isEqualToString:SameScreenUndoPreviousPath]) {
[_webView undo]; [_webView undo];
}else if ([action isEqualToString:SameScreenMarkReq]) {
[self dealWithMarkOperateReq:param];
}else if ([action isEqualToString:SameScreenMarkAnswer]) {
[self dealWithMarkOperateAnswer:param];
}else if ([action isEqualToString:SameScreenMarkCallback]) {
[self dealWithMarkOperateCallback:param];
} }
} }
- (void)sendshowSameScreenViewNotification - (void)beginSameScreenAction
{ {
if (_webView) { if (_webView) {
[self sameScreenSynchronizeViewSize]; [self sameScreenSynchronizeViewSize];
[self sendCustomSysMsgWithParam:[_webView getShowDic] action:SameScreenOpenView]; [self sendCustomSysMsgWithParam:[_webView getShowDic] action:SameScreenOpenView];
[_webView initHeartBeat];
} }
} }
- (void)sendDismissSameScreenViewNotification - (void)cancelSameScreencAction
{ {
[self sendCustomSysMsgWithParam:@{} action:SameScreenCloseView]; [self sendCustomSysMsgWithParam:@{} action:SameScreenCloseView];
[_webView destoryHeartBeat];
} }
- (void)requestForSameScreenOperateAuthority - (void)requestForSameScreenOperateAuthority
...@@ -149,6 +149,12 @@ ...@@ -149,6 +149,12 @@
[self sendCustomSysMsgWithParam:@{@"uid": requesterUid} action:SameScreenOperateCallback]; [self sendCustomSysMsgWithParam:@{@"uid": requesterUid} action:SameScreenOperateCallback];
} }
- (void)giveUpTheSameScreenOperateAuthority
{
[_webView updateOperateStatus:NO];
[self sendCustomSysMsgWithParam:@{@"uid": [[[NIMSDK sharedSDK] loginManager] currentAccount]} action:SameScreenOperateGiveUp];
}
- (void)openMark - (void)openMark
{ {
...@@ -162,6 +168,20 @@ ...@@ -162,6 +168,20 @@
[self sendCustomSysMsgWithParam:@{} action:SameScreenCloseMark]; [self sendCustomSysMsgWithParam:@{} action:SameScreenCloseMark];
} }
- (void)clearCanvas
{
[_webView clearCanvas];
[self sendCustomSysMsgWithParam:@{} action:SameScreenClearCanvas];
}
- (void)undoCanvas
{
[_webView undo];
[self sendCustomSysMsgWithParam:@{} action:SameScreenUndoPreviousPath];
}
- (void)requestForMarkOperateAuthority - (void)requestForMarkOperateAuthority
{ {
[self sendCustomSysMsgWithParam:@{@"uid":[[[NIMSDK sharedSDK] loginManager] currentAccount]} action:SameScreenMarkReq]; [self sendCustomSysMsgWithParam:@{@"uid":[[[NIMSDK sharedSDK] loginManager] currentAccount]} action:SameScreenMarkReq];
...@@ -184,12 +204,12 @@ ...@@ -184,12 +204,12 @@
#pragma mark - sendCustomSysMsg #pragma mark - sendCustomSysMsg
- (void)sendCustomSysMsgWithParam:(NSDictionary *)param action:(NSString *)action - (void)sendCustomSysMsgWithParam:(NSDictionary *)param action:(NSString *)action
{ {
if (!param) { if (action.length <= 0) {
return; return;
} }
NSDictionary *dict = @{ NSDictionary *dict = @{
@"id" : @(99), @"id" : @(99),
@"content" : param, @"content" : @{@"param": param, @"action":action},
}; };
NSData *data = [NSJSONSerialization dataWithJSONObject:dict NSData *data = [NSJSONSerialization dataWithJSONObject:dict
options:0 options:0
...@@ -240,36 +260,15 @@ ...@@ -240,36 +260,15 @@
} }
} }
- (void)dealWithMarkOperateReq:(NSDictionary *)param - (void)dealWithOperateGiveUp
{ {
if (self.isManager) { if (self.isManager) {
if ([_delegate respondsToSelector:@selector(sameScreenReceiveMarkOperateReqWithUid:)]) { if ([_delegate respondsToSelector:@selector(sameScreenReceiveOperateAbandonNotification)]) {
[_delegate sameScreenReceiveMarkOperateReqWithUid:param[@"uid"]]; [_delegate sameScreenReceiveOperateAbandonNotification];
} }
[_webView updateOperateStatus:YES];
} }
} }
- (void)dealWithMarkOperateAnswer:(NSDictionary *)param
{
NSString *uid = param[@"uid"];
if ([uid isEqualToString:[[[NIMSDK sharedSDK] loginManager] currentAccount]]) {
BOOL isApprove = [param[@"approve"] isEqualToString:@"1"];
if ([_delegate respondsToSelector:@selector(sameScreenReceiveMarkOperateReqResult:)]) {
[_delegate sameScreenReceiveMarkOperateReqResult:isApprove];
}
[_webView updateMarkOperateStatus:isApprove];
}
}
- (void)dealWithMarkOperateCallback:(NSDictionary *)param
{
NSString *uid = param[@"uid"];
if ([uid isEqualToString:[[[NIMSDK sharedSDK] loginManager] currentAccount]]) {
if ([_delegate respondsToSelector:@selector(sameScreenReceiveMarkOperateCallBackNotification)]) {
[_delegate sameScreenReceiveMarkOperateCallBackNotification];
}
[_webView updateMarkOperateStatus:NO];
}
}
@end @end
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
[MBHUDTool showMessage:error.domain]; [MBHUDTool showMessage:error.domain];
}else { }else {
TraceS(@"云信登陆成功"); TraceS(@"云信登陆成功");
strongSelf.otherUid = @"hzyw77846977063892487"; strongSelf.otherUid = @"hzyw1361981094084900";
strongSelf.userLabel.text = @"用户3已经登陆"; strongSelf.userLabel.text = @"用户3已经登陆";
[strongSelf updateViewWhenLoginSuccess]; [strongSelf updateViewWhenLoginSuccess];
} }
...@@ -171,7 +171,9 @@ ...@@ -171,7 +171,9 @@
// vc.needCreate = YES; // vc.needCreate = YES;
// [self presentViewController:vc animated:YES completion:nil]; // [self presentViewController:vc animated:YES completion:nil];
YUNXINDemoViewController *vc = [[YUNXINDemoViewController alloc] init]; YUNXINDemoViewController *vc = [[YUNXINDemoViewController alloc] init];
vc.otherUid = @"hzyw77846977063892487"; vc.otherUid = @"hzyw79241709669453946";
// vc.otherUid = self.otherUid;
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:vc animated:YES completion:nil]; [self presentViewController:vc animated:YES completion:nil];
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#import "CHSameScreenAttachment.h" #import "CHSameScreenAttachment.h"
#import "NTESCustomSysNotificationSender.h" #import "NTESCustomSysNotificationSender.h"
#import "CHPIngAttachment.h" #import "CHPIngAttachment.h"
#import "YUNXINSameScreenManager.h"
NSString *NTESCustomNotificationCountChanged = @"NTESCustomNotificationCountChanged"; NSString *NTESCustomNotificationCountChanged = @"NTESCustomNotificationCountChanged";
...@@ -210,6 +211,7 @@ NIMRTSManagerDelegate,NIMChatManagerDelegate,NIMBroadcastManagerDelegate, NIMSig ...@@ -210,6 +211,7 @@ NIMRTSManagerDelegate,NIMChatManagerDelegate,NIMBroadcastManagerDelegate, NIMSig
NSDictionary *contentDic = [dict objectForKey:NTESCustomContent]; NSDictionary *contentDic = [dict objectForKey:NTESCustomContent];
TraceS(@"收到消息:%@",contentDic); TraceS(@"收到消息:%@",contentDic);
[[NSNotificationCenter defaultCenter] postNotificationName:MutiFaceSameScrrenNotification object:contentDic]; [[NSNotificationCenter defaultCenter] postNotificationName:MutiFaceSameScrrenNotification object:contentDic];
[[YUNXINSameScreenManager shareInstance] receiveCustomSysMsg:contentDic];
} }
break; break;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册登录 后发表评论