Commit b97fb1a73d131c155453aaf5c2ca6b503c2c2601

Authored by 王军波
1 parent be9ebbfa

判断是否登陆,连接聊天服务器

LiveVideoCloud/AppDelegate/AppDelegate.m
... ... @@ -51,16 +51,23 @@
51 51  
52 52 // 20170327 20170328
53 53  
54   -
55   - CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"2017063339" name:@"设计的" portrait:@"http://b.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=f0c5c08030d3d539c16807c70fb7c566/8ad4b31c8701a18bbef9f231982f07082838feba.jpg"];
56   -
57   -
58   - [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) {
59   - NSLog(@"连接服务器-----success");
  54 + if ([UserTools isLogin]) {
  55 +
  56 + CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:[UserInformationModel manager].uid name:[UserInformationModel manager].nickname portrait:[UserInformationModel manager].faceUrl];
  57 +
  58 + [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) {
  59 + NSLog(@"连接服务器-----success");
  60 + } error:^(CNLiveChatConnectErrorCode errors) {
  61 + NSLog(@"连接服务器失败-----%ld", errors);
  62 + }];
  63 + } else {
60 64  
61   - } error:^(CNLiveChatConnectErrorCode errors) {
62   - NSLog(@"连接服务器失败-----%ld", errors);
63   - }];
  65 + [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
  66 + NSLog(@"连接服务器-----success");
  67 + } error:^(CNLiveChatConnectErrorCode errors) {
  68 + NSLog(@"连接服务器失败-----%ld", errors);
  69 + }];
  70 + }
64 71  
65 72 [self.window makeKeyAndVisible];
66 73  
... ...