| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- //
- // MessageListViewController.m
- // 千模
- //
- // Created by MUMEI on 2018/6/28.
- // Copyright © 2018年 MUMEI. All rights reserved.
- //
- #import "MessageListViewController.h"
- #import "MessageViewController.h"
- #import "NTESVideoChatViewController.h"
- @interface MessageListViewController ()<NIMNetCallManagerDelegate>
- @end
- @implementation MessageListViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"会话";
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tcpConnectStateChange) name:@"reloadUnRead" object:nil];
- NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:[Helper sharedAccount].accid];
- NSLog(@"user = %@",user);
- // [[NIMKit sharedKit] setProvider:[NTESDataProvider new]];
- //
- //// [[NIMKit sharedKit] setProvider:[NTESDataProvider new]];
- //
- // NIMSession *session = [NIMSession session:@"hoong" type:NIMSessionTypeP2P];
- // NIMTipObject *object = [[NIMTipObject alloc] init];
- //
- // NIMMessage *message = [[NIMMessage alloc] init];
- // message.messageObject = object;
- // message.text = @"可以开始对话了";
- // NIMKitInfoFetchOption *option = [[NIMKitInfoFetchOption alloc] init];
- // option.session = session;
- // NIMKitInfo *info = [[NIMKit sharedKit] infoByUser:@"hoong" option:option];
- // // 错误反馈对象
- // NSError *error = nil;
- // // 发送消息
- // [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:&error];
- [[NIMAVChatSDK sharedSDK].netCallManager addDelegate:self];
- // [[NIMSDK sharedSDK].userManager updateMyUserInfo:@{@(NIMUserInfoUpdateTagAvatar) : [NSString stringWithFormat:@"%@%@",imageURl,user.userInfo.avatarUrl]} completion:nil];
- // Do any additional setup after loading the view.
- }
- - (void)viewWillAppear:(BOOL)animated{
- [self changeLoginState:@"1"];
- NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount];
- self.navigationController.tabBarItem.badgeValue = count ? [NSString stringWithFormat:@"%ld",count] : nil;
- }
- - (void)tcpConnectStateChange{
- NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount];
- self.navigationController.tabBarItem.badgeValue = count ? [NSString stringWithFormat:@"%ld",count] : nil;
- }
- - (void)onLogin:(NIMLoginStep)step{
- if (step == NIMLoginStepSyncOK) {
- [self.tableView reloadData];
- }
- }
- - (void)changeLoginState:(NSString *)state{
-
- NSString *str = [NSString stringWithFormat:@"%@modelInfo?action=doPutOnline&modelpk=%@&online=%@",imageURl,[ModelUser user].modelpk,state];
- [[AHHttpManager sharedManager]POST:str parameters:nil success:^(id responseObject) {
- NSLog(@"%@",responseObject);
- if ([[responseObject objectForKey:@"msg"]isEqualToString:@"success"]) {
-
- }else{
-
- }
- } failure:^(NSError *error) {
- NSLog(@"error = %@",error);
- }];
- }
- - (NSInteger)findInsertPlace:(NIMRecentSession *)recentSession{
- __block NSUInteger matchIdx = 0;
- __block BOOL find = NO;
- [self.recentSessions enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- NIMRecentSession *item = obj;
- if (item.lastMessage.timestamp <= recentSession.lastMessage.timestamp && ![item.lastMessage.session.sessionId isEqualToString:@"system"]) {
- *stop = YES;
- find = YES;
- matchIdx = idx;
- }
- }];
- if (find) {
- return matchIdx;
- }else{
- return self.recentSessions.count;
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)onSelectedRecent:(NIMRecentSession *)recentSession atIndexPath:(NSIndexPath *)indexPath{
- MessageViewController *vc = [[MessageViewController alloc] initWithSession:recentSession.session];
- // vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- //- (void)onReceive:(UInt64)callID from:(NSString *)caller type:(NIMNetCallMediaType)type message:(NSString *)extendMessage{
- //
- // // NTESMainTabController *tabVC = [NTESMainTabController instance];
- // // [tabVC.view endEditing:YES];
- // // UINavigationController *nav = tabVC.selectedViewController;
- // //
- // // if ([self shouldResponseBusy]){
- // // [[NIMAVChatSDK sharedSDK].netCallManager control:callID type:NIMNetCallControlTypeBusyLine];
- // // }
- // // else {
- // //
- // // if ([self shouldFireNotification:caller]) {
- // // NSString *text = [self textByCaller:caller
- // // type:type];
- // // [_notifier start:text];
- // // }
- // UIViewController *vc;
- // switch (type) {
- // case NIMNetCallTypeVideo:{
- // vc = [[NTESVideoChatViewController alloc] initWithCaller:caller callId:callID];
- // NSLog(@"11111");
- //// [self response:NO];
- // }
- // break;
- // case NIMNetCallTypeAudio:{
- // // vc = [[NTESAudioChatViewController alloc] initWithCaller:caller callId:callID];
- // }
- // break;
- // default:
- // break;
- // }
- // if (!vc) {
- // return;
- // }
- //
- // // 由于音视频聊天里头有音频和视频聊天界面的切换,直接用present的话页面过渡会不太自然,这里还是用push,然后做出present的效果
- // // CATransition *transition = [CATransition animation];
- // // transition.duration = 0.25;
- // // transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
- // // transition.type = kCATransitionPush;
- // // transition.subtype = kCATransitionFromTop;
- // // [nav.view.layer addAnimation:transition forKey:nil];
- // // nav.navigationBarHidden = YES;
- // // if (nav.presentedViewController) {
- // // // fix bug MMC-1431
- // // [nav.presentedViewController dismissViewControllerAnimated:NO completion:nil];
- // // }
- // // [nav pushViewController:vc animated:NO];
- // // }
- //// [self presentViewController:vc
- //// animated:YES
- //// completion:nil];
- // vc.hidesBottomBarWhenPushed = YES;
- // [self.navigationController pushViewController:vc animated:NO];
- //}
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|