标签:style blog color io os ar for sp div
到这里、 我们封装了XMPP 登录、 注册、 好友列表获取、 好友状态获取、 信息的收发、
应该去测试一下了 、 我这里把最简单的测试办法扔到这里、 大家可以看一下 。
1 // 2 // ADViewController.m 3 // ADXMPP_BE 4 // 5 // Created by Dylan on 14-10-8. 6 // Copyright (c) 2014年 Dylan. All rights reserved. 7 // 8 9 #import "ADViewController.h" 10 #import "ADMessageModel.h" 11 12 @interface ADViewController () 13 14 @end 15 16 @implementation ADViewController 17 18 - (void)viewDidLoad 19 { 20 [super viewDidLoad]; 21 22 23 // testLogin 24 [XMPPHANDLE connectionWithUserName:@"dylan@127.0.0.1" passWord:@"admin" success:^{ 25 NSLog(@"success"); 26 27 [XMPPHANDLE refreshRosterPresence:^(NSString * userID) { 28 29 NSLog(@"%@%@", userID, DOMAINS); 30 } offline:^(NSString * userID) { 31 32 NSLog(@"%@%@", userID, DOMAINS); 33 }]; 34 35 [XMPPHANDLE refreshRosterList:^(id dict) { 36 NSLog(@"%@", dict); 37 38 } failure:^(id error) { 39 NSLog(@"%@", error); 40 }]; 41 42 // testMsg 43 [[NSUserDefaults standardUserDefaults] setValue:@"alice@127.0.0.1/xueyulundeMacBook-Pro" forKey:CURRENT_CHAT]; 44 [XMPPHANDLE setNewMessage:^(id dict) { 45 NSLog(@"%@", dict); 46 }]; 47 48 ADMessageModel * model = [[ADMessageModel alloc] init]; 49 model.from = [NSString stringWithFormat:@"%@", XMPPHANDLE.xmppStream.myJID]; 50 model.to = [[NSUserDefaults standardUserDefaults] stringForKey:CURRENT_CHAT]; 51 model.body = @"Hello"; 52 53 [XMPPHANDLE sendMessage:model sendSuccess:^{ 54 55 NSLog(@"send success"); 56 57 } sendFailure:^(id error) { 58 NSLog(@"%@", error); 59 }]; 60 61 } failure:^(id error) { 62 NSLog(@"error"); 63 }]; 64 65 // testRegis 66 // [XMPPHANDLE registerWithUserName:@"test" passWord:@"admin" success:^{ 67 // NSLog(@"register success"); 68 // } failure:^(id error) { 69 // NSLog(@"%@", error); 70 // }]; 71 } 72 73 - (void)didReceiveMemoryWarning 74 { 75 [super didReceiveMemoryWarning]; 76 } 77 78 @end
特别需要注意的是代码的执行先后顺序。
代理执行方法的先后顺序
保证自己的Block方法体可以被寻找到
标签:style blog color io os ar for sp div
原文地址:http://www.cnblogs.com/Dylan-Alice/p/Dylan_XMPPsmall.html