|
6#
楼主 |
发表于 2015-10-14 18:00:51
|
只看该作者
[AnyChatPlatform Connect:[AppDelegate GetServerIP] : [AppDelegate GetServerPort]];
[AnyChatPlatform Login:[Account mobile] : [Account password]];连接登录;
NSMutableArray *userList = [AnyChatPlatform GetUserFriends];获取列表;
NSString* str = _shebeiNum.text;
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
[AnyChatPlatform EnterRoom:1 :@""];进入房间
[AnyChatPlatform TransBuffer:-1 :data];添加好友;
// 透明通道回调函数
- (void)OnAnyChatTransBufferCallBack:(int)dwUserid :(NSData *)lpBuf{
[HUD_SHOW afterRemove];
NSString* newStr = [[NSString alloc] initWithData:lpBuf encoding:NSUTF8StringEncoding];
NSData *JSONData = [newStr dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableLeaves error:nil];
if([[responseJSON valueForKey:@"status"] isEqualToString:@"success"]){
[SVProgressHUD showErrorWithStatus:@"切换成功"];
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:@"sendDataToServer1" object:nil];
NSLog(@"添加朋友开始");
NSString *str = [NSString stringWithFormat:@"addfriend:%d", dwUserid];
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
[AnyChatPlatform TransBuffer:-1 :data];
//
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:@"sendDataToServer" object:nil];
//
NSLog(@"添加朋友结束");
[SVProgressHUD showErrorWithStatus:NSLocalizedString(@"bind_device_success",nil)];
[[NSNotificationCenter defaultCenter] postNotificationName:@"RefreshUserList" object:nil];
// [homeTC reloadDeviceList];
// [self showHomeView];
}
NSLog(@"通道回调:%@", newStr);
}
|
|