Commit 059adb720564db1a27136184404bbe10eef1fea7

Authored by 王军波
1 parent 94121183

Demo增加获取聊天室人数

CNLiveChatSDKDemo/CNLiveChatManager.framework/CNLiveChatManager
No preview for this file type
CNLiveChatSDKDemo/CNLiveChatSDKDemo.xcodeproj/project.pbxproj
@@ -7,12 +7,14 @@ @@ -7,12 +7,14 @@
7 objects = { 7 objects = {
8 8
9 /* Begin PBXBuildFile section */ 9 /* Begin PBXBuildFile section */
  10 + D20C82AB1EEE892400BB609F /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D20C82AA1EEE892400BB609F /* CNLiveChatManager.framework */; };
  11 + D20C82AD1EEE892800BB609F /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D20C82AA1EEE892400BB609F /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
  12 + D20C82AF1EEE892B00BB609F /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D20C82A81EEE891D00BB609F /* CNLiveMsgTools.framework */; };
  13 + D20C82B01EEE892B00BB609F /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D20C82A81EEE891D00BB609F /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
10 D2239CD41EE94F31005572FB /* praiseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2239CD31EE94F31005572FB /* praiseModel.m */; }; 14 D2239CD41EE94F31005572FB /* praiseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2239CD31EE94F31005572FB /* praiseModel.m */; };
11 D231941F1E70101500111C3B /* MessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D231941E1E70101500111C3B /* MessageModel.m */; }; 15 D231941F1E70101500111C3B /* MessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D231941E1E70101500111C3B /* MessageModel.m */; };
12 D231C8A61E6FFC2700EAC427 /* ChatRoomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */; }; 16 D231C8A61E6FFC2700EAC427 /* ChatRoomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */; };
13 D231C8A91E6FFD3100EAC427 /* PrivateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */; }; 17 D231C8A91E6FFD3100EAC427 /* PrivateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */; };
14 - D244EFE61EE9176200C1B9DB /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2868FED1EE916780037DECF /* CNLiveChatManager.framework */; };  
15 - D244EFE71EE9176200C1B9DB /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2868FED1EE916780037DECF /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };  
16 D244EFEA1EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D244EFE91EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m */; }; 18 D244EFEA1EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D244EFE91EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m */; };
17 D264D5A51E6FDE02002CDF41 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A41E6FDE02002CDF41 /* main.m */; }; 19 D264D5A51E6FDE02002CDF41 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A41E6FDE02002CDF41 /* main.m */; };
18 D264D5A81E6FDE02002CDF41 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A71E6FDE02002CDF41 /* AppDelegate.m */; }; 20 D264D5A81E6FDE02002CDF41 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A71E6FDE02002CDF41 /* AppDelegate.m */; };
@@ -21,19 +23,17 @@ @@ -21,19 +23,17 @@
21 D264D5B01E6FDE02002CDF41 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D264D5AF1E6FDE02002CDF41 /* Assets.xcassets */; }; 23 D264D5B01E6FDE02002CDF41 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D264D5AF1E6FDE02002CDF41 /* Assets.xcassets */; };
22 D264D5B31E6FDE02002CDF41 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D264D5B11E6FDE02002CDF41 /* LaunchScreen.storyboard */; }; 24 D264D5B31E6FDE02002CDF41 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D264D5B11E6FDE02002CDF41 /* LaunchScreen.storyboard */; };
23 D2868FEC1EE914690037DECF /* CommentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2868FEB1EE914690037DECF /* CommentViewController.m */; }; 25 D2868FEC1EE914690037DECF /* CommentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2868FEB1EE914690037DECF /* CommentViewController.m */; };
24 - D2CE6F001EE80EE7007CEA51 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2CE6EFF1EE80EE7007CEA51 /* CNLiveMsgTools.framework */; };  
25 - D2CE6F061EE80EF6007CEA51 /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2CE6EFF1EE80EE7007CEA51 /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };  
26 /* End PBXBuildFile section */ 26 /* End PBXBuildFile section */
27 27
28 /* Begin PBXCopyFilesBuildPhase section */ 28 /* Begin PBXCopyFilesBuildPhase section */
29 - D264D5C11E6FE301002CDF41 /* Embed Frameworks */ = { 29 + D20C82AE1EEE892900BB609F /* Embed Frameworks */ = {
30 isa = PBXCopyFilesBuildPhase; 30 isa = PBXCopyFilesBuildPhase;
31 buildActionMask = 2147483647; 31 buildActionMask = 2147483647;
32 dstPath = ""; 32 dstPath = "";
33 dstSubfolderSpec = 10; 33 dstSubfolderSpec = 10;
34 files = ( 34 files = (
35 - D2CE6F061EE80EF6007CEA51 /* CNLiveMsgTools.framework in Embed Frameworks */,  
36 - D244EFE71EE9176200C1B9DB /* CNLiveChatManager.framework in Embed Frameworks */, 35 + D20C82AD1EEE892800BB609F /* CNLiveChatManager.framework in Embed Frameworks */,
  36 + D20C82B01EEE892B00BB609F /* CNLiveMsgTools.framework in Embed Frameworks */,
37 ); 37 );
38 name = "Embed Frameworks"; 38 name = "Embed Frameworks";
39 runOnlyForDeploymentPostprocessing = 0; 39 runOnlyForDeploymentPostprocessing = 0;
@@ -41,6 +41,8 @@ @@ -41,6 +41,8 @@
41 /* End PBXCopyFilesBuildPhase section */ 41 /* End PBXCopyFilesBuildPhase section */
42 42
43 /* Begin PBXFileReference section */ 43 /* Begin PBXFileReference section */
  44 + D20C82A81EEE891D00BB609F /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };
  45 + D20C82AA1EEE892400BB609F /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; };
44 D2239CD21EE94F31005572FB /* praiseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = praiseModel.h; sourceTree = "<group>"; }; 46 D2239CD21EE94F31005572FB /* praiseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = praiseModel.h; sourceTree = "<group>"; };
45 D2239CD31EE94F31005572FB /* praiseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = praiseModel.m; sourceTree = "<group>"; }; 47 D2239CD31EE94F31005572FB /* praiseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = praiseModel.m; sourceTree = "<group>"; };
46 D231941D1E70101500111C3B /* MessageModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageModel.h; sourceTree = "<group>"; }; 48 D231941D1E70101500111C3B /* MessageModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageModel.h; sourceTree = "<group>"; };
@@ -64,8 +66,6 @@ @@ -64,8 +66,6 @@
64 D264D5BE1E6FDEED002CDF41 /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = "<group>"; }; 66 D264D5BE1E6FDEED002CDF41 /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = "<group>"; };
65 D2868FEA1EE914690037DECF /* CommentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentViewController.h; sourceTree = "<group>"; }; 67 D2868FEA1EE914690037DECF /* CommentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentViewController.h; sourceTree = "<group>"; };
66 D2868FEB1EE914690037DECF /* CommentViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentViewController.m; sourceTree = "<group>"; }; 68 D2868FEB1EE914690037DECF /* CommentViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentViewController.m; sourceTree = "<group>"; };
67 - D2868FED1EE916780037DECF /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; };  
68 - D2CE6EFF1EE80EE7007CEA51 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };  
69 /* End PBXFileReference section */ 69 /* End PBXFileReference section */
70 70
71 /* Begin PBXFrameworksBuildPhase section */ 71 /* Begin PBXFrameworksBuildPhase section */
@@ -73,8 +73,8 @@ @@ -73,8 +73,8 @@
73 isa = PBXFrameworksBuildPhase; 73 isa = PBXFrameworksBuildPhase;
74 buildActionMask = 2147483647; 74 buildActionMask = 2147483647;
75 files = ( 75 files = (
76 - D2CE6F001EE80EE7007CEA51 /* CNLiveMsgTools.framework in Frameworks */,  
77 - D244EFE61EE9176200C1B9DB /* CNLiveChatManager.framework in Frameworks */, 76 + D20C82AF1EEE892B00BB609F /* CNLiveMsgTools.framework in Frameworks */,
  77 + D20C82AB1EEE892400BB609F /* CNLiveChatManager.framework in Frameworks */,
78 ); 78 );
79 runOnlyForDeploymentPostprocessing = 0; 79 runOnlyForDeploymentPostprocessing = 0;
80 }; 80 };
@@ -119,8 +119,8 @@ @@ -119,8 +119,8 @@
119 D264D5971E6FDE02002CDF41 = { 119 D264D5971E6FDE02002CDF41 = {
120 isa = PBXGroup; 120 isa = PBXGroup;
121 children = ( 121 children = (
122 - D2868FED1EE916780037DECF /* CNLiveChatManager.framework */,  
123 - D2CE6EFF1EE80EE7007CEA51 /* CNLiveMsgTools.framework */, 122 + D20C82AA1EEE892400BB609F /* CNLiveChatManager.framework */,
  123 + D20C82A81EEE891D00BB609F /* CNLiveMsgTools.framework */,
124 D264D5A21E6FDE02002CDF41 /* CNLiveChatSDKDemo */, 124 D264D5A21E6FDE02002CDF41 /* CNLiveChatSDKDemo */,
125 D264D5A11E6FDE02002CDF41 /* Products */, 125 D264D5A11E6FDE02002CDF41 /* Products */,
126 ); 126 );
@@ -170,7 +170,7 @@ @@ -170,7 +170,7 @@
170 D264D59C1E6FDE02002CDF41 /* Sources */, 170 D264D59C1E6FDE02002CDF41 /* Sources */,
171 D264D59D1E6FDE02002CDF41 /* Frameworks */, 171 D264D59D1E6FDE02002CDF41 /* Frameworks */,
172 D264D59E1E6FDE02002CDF41 /* Resources */, 172 D264D59E1E6FDE02002CDF41 /* Resources */,
173 - D264D5C11E6FE301002CDF41 /* Embed Frameworks */, 173 + D20C82AE1EEE892900BB609F /* Embed Frameworks */,
174 ); 174 );
175 buildRules = ( 175 buildRules = (
176 ); 176 );
CNLiveChatSDKDemo/CNLiveChatSDKDemo/ChatRoomViewController.m
@@ -18,6 +18,8 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -18,6 +18,8 @@ static NSString *cellId = @&quot;cellId&quot;;
18 18
19 @property (nonatomic, strong) UITextField *textField; 19 @property (nonatomic, strong) UITextField *textField;
20 20
  21 +@property (nonatomic, strong) UILabel *chatRoomPersonCountLabel;
  22 +
21 @property (nonatomic, strong) UITableView *tableView; 23 @property (nonatomic, strong) UITableView *tableView;
22 24
23 @end 25 @end
@@ -38,6 +40,13 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -38,6 +40,13 @@ static NSString *cellId = @&quot;cellId&quot;;
38 [[CNLiveChatManager sharedCNLiveChatManager] joinChatRoom:@"67_7788" messageCount:10 success:^(NSString *targetId) { 40 [[CNLiveChatManager sharedCNLiveChatManager] joinChatRoom:@"67_7788" messageCount:10 success:^(NSString *targetId) {
39 41
40 NSLog(@"已成功加入聊天室:%@",targetId); 42 NSLog(@"已成功加入聊天室:%@",targetId);
  43 + [self getChatRoomPersonCount];
  44 +
  45 + dispatch_async(dispatch_get_global_queue(0, 0), ^{
  46 + [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(getChatRoomPersonCount) userInfo:nil repeats:YES];
  47 + [[NSRunLoop currentRunLoop] run];
  48 + });
  49 +
41 50
42 } error:^(CNLiveChatErrorCode errors, NSString *targetId) { 51 } error:^(CNLiveChatErrorCode errors, NSString *targetId) {
43 52
@@ -49,6 +58,7 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -49,6 +58,7 @@ static NSString *cellId = @&quot;cellId&quot;;
49 gestureRecognizer.cancelsTouchesInView = YES; 58 gestureRecognizer.cancelsTouchesInView = YES;
50 [self.tableView addGestureRecognizer:gestureRecognizer]; 59 [self.tableView addGestureRecognizer:gestureRecognizer];
51 [self.view addSubview:self.textField]; 60 [self.view addSubview:self.textField];
  61 + [self.view addSubview:self.chatRoomPersonCountLabel];
52 62
53 _messageArrayM = [[NSMutableArray alloc] init]; 63 _messageArrayM = [[NSMutableArray alloc] init];
54 } 64 }
@@ -65,26 +75,22 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -65,26 +75,22 @@ static NSString *cellId = @&quot;cellId&quot;;
65 } 75 }
66 76
67 77
68 -#pragma mark - 懒加载 !!!!!!!!!!!!!!!!!!!!!!!!!!  
69 -- (UITextField *)textField { 78 +#pragma mark - 获取聊天室人数
  79 +- (void)getChatRoomPersonCount {
70 80
71 - if (!_textField) {  
72 - _textField = [self createTextFieldWithFrame:CGRectMake(10, 74, KScreenWidth - 20, 40) font:20];  
73 - _textField.delegate = self;  
74 - }  
75 - return _textField; 81 + [[CNLiveChatManager sharedCNLiveChatManager] getChatRoomInfo:@"67_7788" success:^(int totalMemberCount) {
  82 +
  83 + NSLog(@"success: %d",totalMemberCount);
  84 + dispatch_async(dispatch_get_main_queue(), ^{
  85 + self.chatRoomPersonCountLabel.text = [NSString stringWithFormat:@"聊天室人数为:%d",totalMemberCount];
  86 + });
  87 +
  88 + } error:^(CNLiveChatErrorCode status) {
  89 +
  90 + NSLog(@"failed");
  91 + }];
76 } 92 }
77 93
78 --(UITableView *)tableView {  
79 - if (!_tableView) {  
80 - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 124, KScreenWidth, KScreenHeight - 425) style:UITableViewStylePlain];  
81 - _tableView.rowHeight = 30;  
82 - _tableView.delegate = self;  
83 - _tableView.dataSource = self;  
84 - [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellId];  
85 - }  
86 - return _tableView;  
87 -}  
88 94
89 #pragma mark - UITableViewDelegate,UITableViewDataSource !!!!!!!!!!!!!!!!!!!!!!!!!! 95 #pragma mark - UITableViewDelegate,UITableViewDataSource !!!!!!!!!!!!!!!!!!!!!!!!!!
90 96
@@ -216,6 +222,36 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -216,6 +222,36 @@ static NSString *cellId = @&quot;cellId&quot;;
216 } 222 }
217 223
218 224
  225 +#pragma mark - Get Method !!!!!!!!!!!!!!!!!!!!!!!!!!
  226 +- (UITextField *)textField {
  227 +
  228 + if (!_textField) {
  229 + _textField = [self createTextFieldWithFrame:CGRectMake(10, 74, KScreenWidth - 20, 40) font:20];
  230 + _textField.delegate = self;
  231 + }
  232 + return _textField;
  233 +}
  234 +
  235 +- (UILabel *)chatRoomPersonCountLabel {
  236 +
  237 + if (!_chatRoomPersonCountLabel) {
  238 + _chatRoomPersonCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 124, KScreenWidth - 20, 35)];
  239 + }
  240 + return _chatRoomPersonCountLabel;
  241 +}
  242 +
  243 +-(UITableView *)tableView {
  244 + if (!_tableView) {
  245 + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 159, KScreenWidth, KScreenHeight - 425) style:UITableViewStylePlain];
  246 + _tableView.rowHeight = 30;
  247 + _tableView.delegate = self;
  248 + _tableView.dataSource = self;
  249 + [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellId];
  250 + }
  251 + return _tableView;
  252 +}
  253 +
  254 +
219 #pragma mark - 创建文本框 !!!!!!!!!!!!!!!!!!!!!!!!!! 255 #pragma mark - 创建文本框 !!!!!!!!!!!!!!!!!!!!!!!!!!
220 - (UITextField *)createTextFieldWithFrame:(CGRect)frame font:(float)font { 256 - (UITextField *)createTextFieldWithFrame:(CGRect)frame font:(float)font {
221 257
CNLiveChatSDKDemo/CNLiveMsgTools.framework/CNLiveMsgTools
No preview for this file type