zoukankan      html  css  js  c++  java
  • XMPP教学小结1

    到这里、 我们封装了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方法体可以被寻找到

  • 相关阅读:
    SQL Server中sys.syslogin中updatedate字段的浅析
    ORACLE 中NUMBER类型默认的精度和Scale问题
    SQL Server中sp_spaceused统计数据使用的空间总量不正确的原因
    Percona XtraBackup 安装介绍篇
    ORACLE中死锁的知识点总结
    Linux如何查看YUM的安装目录
    find: missing argument to `-exec'
    Linux平台下RMAN异机恢复总结
    WARNING: Re-reading the partition table failed with error 22: Invalid argument
    Windows Server 2012更新补丁后导致Micosoft ODBC for Oracle出现问题
  • 原文地址:https://www.cnblogs.com/Dylan-Alice/p/Dylan_XMPPsmall.html
Copyright © 2011-2022 走看看