Commit c98d5890 by zhangyunjie

demo

parent e9673ded
......@@ -208,6 +208,7 @@
A9D1B31824EFAD8C000F4662 /* OffcnUploadManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A9D1B31724EFAD8C000F4662 /* OffcnUploadManager.m */; };
A9D1B31B24F34C25000F4662 /* OffcnIMSocketManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A9D1B31A24F34C25000F4662 /* OffcnIMSocketManager.m */; };
A9D1B32224F50973000F4662 /* OffcnIMModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A9D1B32124F50973000F4662 /* OffcnIMModel.m */; };
A9D1B32E24F7BE7B000F4662 /* OffcnZYJTestDataStorageView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9D1B32C24F7BE7B000F4662 /* OffcnZYJTestDataStorageView.m */; };
B94FCB1053F8932068A11CC9 /* libPods-OffcnIMSDKiOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 49CE5E230A14D9B821170F61 /* libPods-OffcnIMSDKiOS.a */; };
/* End PBXBuildFile section */
......@@ -644,6 +645,8 @@
A9D1B31A24F34C25000F4662 /* OffcnIMSocketManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OffcnIMSocketManager.m; sourceTree = "<group>"; };
A9D1B32024F50973000F4662 /* OffcnIMModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OffcnIMModel.h; sourceTree = "<group>"; };
A9D1B32124F50973000F4662 /* OffcnIMModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OffcnIMModel.m; sourceTree = "<group>"; };
A9D1B32C24F7BE7B000F4662 /* OffcnZYJTestDataStorageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OffcnZYJTestDataStorageView.m; sourceTree = "<group>"; };
A9D1B32D24F7BE7B000F4662 /* OffcnZYJTestDataStorageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OffcnZYJTestDataStorageView.h; sourceTree = "<group>"; };
D7DCDED1DEE7F99F223D5C73 /* Pods-OffcnIMSDKiOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OffcnIMSDKiOS.release.xcconfig"; path = "Target Support Files/Pods-OffcnIMSDKiOS/Pods-OffcnIMSDKiOS.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -704,6 +707,8 @@
A9661B5E24EA72900024EB54 /* AppDelegate.m */,
A9661B5D24EA72900024EB54 /* ViewController.h */,
A9661B5F24EA72900024EB54 /* ViewController.mm */,
A9D1B32D24F7BE7B000F4662 /* OffcnZYJTestDataStorageView.h */,
A9D1B32C24F7BE7B000F4662 /* OffcnZYJTestDataStorageView.m */,
A9661B6224EA729A0024EB54 /* Main.storyboard */,
A9661B4F24EA64F20024EB54 /* Assets.xcassets */,
A9661B5124EA64F20024EB54 /* LaunchScreen.storyboard */,
......@@ -1635,6 +1640,7 @@
A9661FD924EA7AD10024EB54 /* SDButton.m in Sources */,
A966219024EA80A60024EB54 /* ZYJMJRefreshAutoNormalFooter.m in Sources */,
A96621CA24EA80A60024EB54 /* ZYJMQTTCFSocketEncoder.m in Sources */,
A9D1B32E24F7BE7B000F4662 /* OffcnZYJTestDataStorageView.m in Sources */,
A966218224EA80A60024EB54 /* ZYJSDWebImagePrefetcher.m in Sources */,
A966216B24EA80A60024EB54 /* ZYJPingHelper.m in Sources */,
A966217324EA80A60024EB54 /* ZYJReachStateWIFI.m in Sources */,
......
//
//
......@@ -61,6 +61,10 @@ static OffcnIMSocketManager *socketManager;
NSString *revStr = [NSString stringWithUTF8String:message];
OffcnIMModel *IMModel = [OffcnIMModel mj_ZYJobjectWithKeyValues:revStr];
NSString *msg_id = IMModel.body.msg_id;
if (!msg_id) {
return;
}
if (self.msgArr.count) {
if ([self.msgArr containsObject:msg_id]) {
//消息重复,丢弃
......@@ -71,6 +75,7 @@ static OffcnIMSocketManager *socketManager;
[self.msgArr addObject:msg_id];
//存数据库
if (self.connectReceiveMessage) {
self.connectReceiveMessage(IMModel);
}
......@@ -78,6 +83,8 @@ static OffcnIMSocketManager *socketManager;
}else{
[self.msgArr addObject:msg_id];
//存数据库
if (self.connectReceiveMessage) {
self.connectReceiveMessage(IMModel);
}
......
//
// OffcnZYJTestDataStorageView.h
// OffcnLiveSDK
//
// Created by zyj on 2020/3/28.
// Copyright © 2020 中公教育. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface OffcnZYJTestDataStorageView : UIView
@property (nonatomic, strong) NSString *msg;
-(instancetype)initWithFrame:(CGRect)frame;
-(void)showView;
-(void)hidView;
@end
NS_ASSUME_NONNULL_END
//
// OffcnZYJTestDataStorageView.m
// OffcnLiveSDK
//
// Created by zyj on 2020/3/28.
// Copyright © 2020 中公教育. All rights reserved.
//
#import "OffcnZYJTestDataStorageView.h"
#import "UIViewExt.h"
#import "SDGeneralDefine.h"
#import "DataSafe.h"
#import "SDGeneralTool.h"
@interface OffcnZYJTestDataStorageView ()
@property (nonatomic, strong) UIButton *pasteBtn;
@property (nonatomic, strong) UIButton *cancellBtn;
@property (nonatomic, strong) UITextView *textView;
@end
@implementation OffcnZYJTestDataStorageView
-(UIButton *)pasteBtn{
if (!_pasteBtn) {
_pasteBtn = [[UIButton alloc] init];
_pasteBtn.titleLabel.font = KFontNameMediumSize(18);
[_pasteBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_pasteBtn setTitle:@"复制" forState:UIControlStateNormal];
[_pasteBtn addTarget:self action:@selector(pasteBtnAction:) forControlEvents:UIControlEventTouchUpInside];
_pasteBtn.backgroundColor = KButtonSelectColor;
}
return _pasteBtn;
}
-(void)pasteBtnAction:(UIButton *)button{
KWeakSelf
dispatch_async(dispatch_get_main_queue(), ^{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = weakSelf.textView.text;
[SDGeneralTool toastWithTitlemessage:@"复制成功"];
});
}
-(UIButton *)cancellBtn{
if (!_cancellBtn) {
_cancellBtn = [[UIButton alloc] init];
_cancellBtn.titleLabel.font = KFontNameMediumSize(18);
[_cancellBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_cancellBtn setTitle:@"关闭" forState:UIControlStateNormal];
[_cancellBtn addTarget:self action:@selector(closeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
_cancellBtn.backgroundColor = KButtonSelectColor;
}
return _cancellBtn;
}
-(void)closeBtnAction:(UIButton *)button{
[self hidView];
}
-(UITextView *)textView{
if (!_textView){
_textView = [[UITextView alloc] initWithFrame:CGRectZero];
_textView.font = KFontNameMediumSize(13);
_textView.textColor = KTextColor;
_textView.textAlignment = NSTextAlignmentLeft;
_textView.linkTextAttributes = @{NSForegroundColorAttributeName:UICOLOR_RGB_Alpha(0x4690f7, 1)};
_textView.backgroundColor = [UIColor clearColor];
_textView.textContainer.lineFragmentPadding = 0;
_textView.textContainerInset = UIEdgeInsetsZero;
_textView.editable = NO;
_textView.scrollEnabled = YES;
_textView.dataDetectorTypes = UIDataDetectorTypeLink;
}
return _textView;
}
-(instancetype)initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor whiteColor];
[self addSubview:self.pasteBtn];
[self addSubview:self.cancellBtn];
[self addSubview:self.textView];
}
return self;
}
-(void)layoutSubviews{
[super layoutSubviews];
self.textView.frame = CGRectMake(20, 0, self.width-40, self.height-30-20);
self.pasteBtn.frame = CGRectMake(20, CGRectGetMaxY(self.textView.frame)+10, (self.width-60)/2, 30);
self.cancellBtn.frame = CGRectMake(CGRectGetMaxX(self.pasteBtn.frame)+20, self.pasteBtn.y, self.pasteBtn.width, self.pasteBtn.height);
}
-(void)showView{
UIWindow *mainWindow = KKeyWindow;
[mainWindow addSubview:self];
[mainWindow bringSubviewToFront:self];
[self setNeedsLayout];
[self layoutIfNeeded];
}
-(void)setMsg:(NSString *)msg{
_msg = msg;
self.textView.text = msg;
}
-(void)hidView{
[self endEditing:YES];
[self removeAllSubViews];
[self removeFromSuperview];
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment