3G数据请求
// 该类负责发送2G/3G Http请求的数据
#import <Foundation/Foundation.h>
#import "ASIHTTPRequest.h"
#import "ASINetworkQueue.h"
#import "ASIDownloadCache.h"
#import "ASIFormDataRequest.h"
#import <SystemConfiguration/CaptiveNetwork.h>
#import "DeviceInfo.h"
@protocolDataRequestManagerDelegate;
//开关状态
#define openCommd @"FE000011010002FFFF1001FFFF2001FFFF3001FFFF"
#define closeCommd @"FE000011010001FFFF1001FFFF2001FFFF3001FFFF"
#define DataBaseURL @"http://yun.lierda.com/usvc/"
//对应的操作
typedefenum
{
DataRequestStart = 0,
SecurityCodeRequest, //验证码
ResignRequest, //注册
LoginRequest, //登陆
AddDeviceRequest, //添加设备
ControlDeviceRequest, //控制设备
QueryDeviceRequest,//查询设备
}DataRequestDataType;
@interface DataRequestManager : NSObject<ASIHTTPRequestDelegate>
@property (nonatomic , assign) id<DataRequestManagerDelegate> delegete;
+ (DataRequestManager *)getInstance;
//1.获取验证码请求接口
- (void)postSecurityCodeWithRequest;
//2.注册接口
- (void)resignWithRequest;
//3.登陆接口
- (void)loginWithRequest;
//4.添加设备
- (void)addDeviceWithRequest:(DeviceInfo *)devInfo;
//5.控制设备
- (void)managerDeviceWithRequest:(NSMutableArray *)devInfoArray isOpen:(BOOL)isopen;
//4.查询设备
- (void)queryDeviceWithInfo:(DeviceInfo *)devInfo;
@end
@protocol DataRequestManagerDelegate <NSObject>
@optional
//发送http数据后的回调
-(void)DataRequestManager:(DataRequestManager *)dataManager receiveData:(NSDictionary *)resultDic errorType:(DataRequestDataType)type;
//发送数据失败
-(void)DataRequestManager:(DataRequestManager *)dataManager receiveData:(NSDictionary *)resultDic successType:(DataRequestDataType)type;
@end
//
// DataRequestManager.m
// SmartHomeWIFI
//
// Created by showsoft_004 on 14-2-27.
// Copyright (c) 2014年 huhuaxiang. All rights reserved.
//
//3G状态获取网络数据
#import "DataRequestManager.h"
#import "SBJson.h"
#import "NetworkTools.h"
#import "UserInfo.h"
#import "UserDataManager.h"
#import "DeviceDataManager.h"
#import "ByteUnit.h"
#define SNKey @"SN"
#define CIDKey @"CID"
#define SIDKey @"SID"
#define captchaPart1Key @"captchaPart1"
#define captchaPart2Key @"captchaPart2"
static DataRequestManager * instance = nil;
@interface DataRequestManager ()
{
ASIHTTPRequest *ordinaryRequest;//基本请求
ASINetworkQueue *requestQueue;
ASIFormDataRequest *requestOfPost;//表单提交
DataRequestDataType currRequestType;
NSMutableDictionary *networkDatas;
UserInfo *regexUserData;
int requestErrorNum;//每次请求的错误数
DeviceInfo *tempDevInfo;
NSMutableArray *controlDeviceArray;
BOOL sendControlDevState;
}
@end
@implementation DataRequestManager
@synthesize delegete;
- (id)init{
self = [super init];
if (self) {
requestQueue = [[ASINetworkQueue alloc] init];
[requestQueue setDelegate:self];
[requestQueue setShouldCancelAllRequestsOnFailure:NO];
[requestQueue setShowAccurateProgress:YES];
if ([requestQueue isSuspended]) {
[requestQueue go];
}
requestErrorNum=0;
networkDatas=[[NSMutableDictionary alloc]init];
}
returnself;
}
- (void)dealloc{
[requestQueue cancelAllOperations];
requestQueue = nil ;
if( ordinaryRequest ){
[ordinaryRequest clearDelegatesAndCancel];
self.delegete = nil;
ordinaryRequest = nil ;
}
if( requestOfPost ){
[requestOfPost clearDelegatesAndCancel];
requestOfPost.delegate = nil;
requestOfPost = nil ;
}
}
+ (DataRequestManager *)getInstance
{
@synchronized(self){
if (instance == nil) {
instance = [[DataRequestManager alloc] init];
}
}
return instance;
}
#pragma mark -- Method
- (NSURL*)generateURL:(NSString*)baseURL params:(NSDictionary*)params {
if (params) {
NSMutableArray* pairs = [NSMutableArray array];
for (NSString* key in params.keyEnumerator) {
NSString* value = [params objectForKey:key];
//please free memory if you use Create, add by hejiang
CFStringRef loc_StringRef=CFURLCreateStringByAddingPercentEscapes(
NULL, /* allocator */
(CFStringRef)value,
NULL, /* charactersToLeaveUnescaped */
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
//NSString* escaped_value = ( NSString *)loc_StringRef;
CFRelease(loc_StringRef);
//escaped_value = nil;//remove warrning escaped_value 作用是什么
[pairs addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
}
NSString* query = [pairs componentsJoinedByString:@"&"];
// query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
query = [query stringByAddingPercentEscapesUsingEncoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000)];
NSString* url = [NSString stringWithFormat:@"%@?%@", baseURL, query];
NSLog(@"-- url = %@",url);
return [NSURLURLWithString:url];
} else {
return [NSURL URLWithString:baseURL];
}
}
//1.输入验证码
- (void)postSecurityCodeWithRequest
{
//请求参数
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
[dic setObject:[NetworkToolsgetLocalMacAddress] forKey:@"phone"];
[dic setObject:[NSStringstringWithFormat:@"%@@ucot.com",[NetworkToolsgetLocalMacAddress]] forKey:@"email"];
[dic setObject:[NSNumbernumberWithInt:500000] forKey:@"timeout"];
[dic setObject:[NSNumbernumberWithInt:0] forKey:@"SN"];
[dic setObject:[NSNumbernumberWithInt:10031] forKey:@"CID"];
[dic setObject:[NSNumbernumberWithInt:1212611785] forKey:@"SID"];
[dic setObject:@"CaptchaReq"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
//发送请求
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=SecurityCodeRequest;
}
//2.注册接口
- (void)resignWithRequest
{
//请求参数
int captchaPart1=[[[networkDatasobjectForKey:[NSNumbernumberWithInt:SecurityCodeRequest]]objectForKey:@"captchaPart1"]integerValue];
int captchaPart2=[[[networkDatasobjectForKey:[NSNumbernumberWithInt:SecurityCodeRequest]]objectForKey:@"captchaPart2"]integerValue];
regexUserData=[[UserInfoalloc]init];
regexUserData.userName=[NSStringstringWithFormat:@"%@@ucot.com",[NetworkToolsgetLocalMacAddress]];
regexUserData.displayName=[NSStringstringWithFormat:@"%@%@",@"shenxianjun",[NetworkToolsgetLocalMacAddress]];
regexUserData.passWord=@"123456";
regexUserData.clientID=@"F0002C0004";
regexUserData.clientMAC=[NetworkToolsgetLocalMacAddress];
regexUserData.clientName=[NetworkToolsgetLocalMacAddress];
regexUserData.CID=10201;
regexUserData.SID=1212611785;
regexUserData.SN=0;
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
// int sn=[[[networkDatas objectForKey:[NSNumber numberWithInt:SecurityCodeRequest]]objectForKey:SNKey]integerValue];
// int CID=10201;//[[[networkDatas objectForKey:[NSNumber numberWithInt:SecurityCodeRequest]]objectForKey:CIDKey]integerValue];
// int SID=[[[networkDatas objectForKey:[NSNumber numberWithInt:SecurityCodeRequest]]objectForKey:SIDKey]integerValue];
[dic setObject:[NSNumbernumberWithInt:regexUserData.SN] forKey:SNKey];
[dic setObject:[NSNumbernumberWithInt:regexUserData.CID] forKey:CIDKey];
[dic setObject:[NSNumbernumberWithInt:regexUserData.SID] forKey:SIDKey];
[dic setObject:[NSString stringWithFormat:@"%d%d",captchaPart1,captchaPart2] forKey:@"captcha"];//验证
[dic setObject:regexUserData.clientIDforKey:@"clientId"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic setObject:@"UserAddReq"forKey:@"NM"];
//userDic
NSMutableDictionary *userDic=[[NSMutableDictionaryalloc]init];
[userDic setObject:regexUserData.displayNameforKey:@"displayName"];
[userDic setObject:regexUserData.userNameforKey:@"userName"];
[userDic setObject:regexUserData.passWordforKey:@"password"];
[userDic setObject:[NetworkTools getLocalMacAddress] forKey:@"phone"];
[userDic setObject:[NSStringstringWithFormat:@"%@@ucot.com",[NetworkToolsgetLocalMacAddress]] forKey:@"email"];
[userDic setObject:[NSStringstringWithFormat:@"%@%@",[NetworkToolsgetLocalMacAddress],@"345676"] forKey:@"idCard"];
[userDic setObject:@"shenzhen"forKey:@"answer"];
[userDic setObject:@"1" forKey:@"questionId"];
[dic setObject:userDic forKey:@"userInfo"];
NSString *json = [selfchangObjectToJsonString:dic];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=ResignRequest;
}
//3.登陆接口
- (void)loginWithRequest
{
regexUserData=[[UserDataManagerinstance]currUserInfo];
if(regexUserData.userName.length<1)//用户没有注册
{
[selfpostSecurityCodeWithRequest];//获取验证码用于注册
return;
}
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
[dic setObject:regexUserData.userNameforKey:@"userName"];
[dic setObject:regexUserData.passWordforKey:@"password"];
[dic setObject:regexUserData.clientIDforKey:@"clientId"];
[dic setObject:regexUserData.clientNameforKey:@"clientName"];
[dic setObject:regexUserData.clientMACforKey:@"mac"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic setObject:regexUserData.clientMACforKey:@"mac"];
[dic setObject:[NSNumbernumberWithInt:10000] forKey:@"agingTime"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.SN] forKey:@"SN"];
[dic setObject:[NSNumbernumberWithInt:10011] forKey:@"CID"];
[dic setObject:[NSNumbernumberWithInt:0] forKey:@"SID"];
[dic setObject:@"loginReq"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=LoginRequest;
}
//4.添加设备
-(void)addDeviceWithRequest:(DeviceInfo *)devInfo
{
tempDevInfo=devInfo;
if(!tempDevInfo)return;
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
[dic setObject:[@"ACCF23123456"uppercaseString] forKey:@"mac"];
// [dic setObject:[devInfo.mac uppercaseString] forKey:@"mac"];
[dic setObject:delaultKeyforKey:@"localkey"];
[dic setObject:devInfo.deviceName forKey:@"name"];
[dic setObject:[NSNumbernumberWithBool:YES] forKey:@"needRemoteControl"];
[dic setObject:@"20140101"forKey:@"serialNo"];
[dic setObject:[NSNumbernumberWithInt:1] forKey:@"factoryId"];
[dic setObject:[NSNumbernumberWithInt:1] forKey:@"type"];
[dic setObject:@"1.0.0"forKey:@"hardwareVer"];
[dic setObject:@"1.0.0"forKey:@"softwareVer"];
[dic setObject:delaultKeyforKey:@"tempKey"];
[dic setObject:[NSNumbernumberWithInt:125.313643243] forKey:@"gpsLat"];
[dic setObject:[NSNumbernumberWithInt:43.89833761] forKey:@"gpsLat"];
[dic setObject:@"CN"forKey:@"country"];
[dic setObject:@"SiChuan"forKey:@"state"];
[dic setObject:@"shenzhen"forKey:@"city"];
[dic setObject:@"None"forKey:@"district"];
[dic setObject:@"mylight.jpg"forKey:@"image"];
NSMutableDictionary *dic2=[[NSMutableDictionaryalloc]init];
[dic2 setObject:dic forKey:@"deviceInfo"];
[dic2 setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic2 setObject:[NSNumbernumberWithInt:0] forKey:@"SN"];
[dic2 setObject:[NSNumbernumberWithInt:30011] forKey:@"CID"];
[dic2 setObject:[NSNumbernumberWithInt:regexUserData.SID] forKey:@"SID"];
[dic2 setObject:@"DeviceAddReq"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic2];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=AddDeviceRequest;
}
//5.控制设备
- (void)managerDeviceWithRequest:(NSMutableArray *)devInfoArray isOpen:(BOOL)isopen
{
controlDeviceArray=devInfoArray;
sendControlDevState=isopen;
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
for (DeviceInfo *info in devInfoArray) {
// [dic setObject:isopen?openCommd:closeCommd forKey:[@"ACCF23123456" uppercaseString]];
[dic setObject:isopen?openCommd:closeCommd forKey:[info.mac uppercaseString]];
}
NSMutableDictionary *dic2=[[NSMutableDictionaryalloc]init];
[dic2 setObject:dic forKey:@"input"];
[dic2 setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic2 setObject:[NSNumbernumberWithInt:0] forKey:@"SN"];
[dic2 setObject:[NSNumbernumberWithInt:20021] forKey:@"CID"];
[dic2 setObject:[NSNumbernumberWithInt:regexUserData.SID] forKey:@"SID"];
[dic2 setObject:@"DeviceGetRep"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic2];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=ControlDeviceRequest;
}
//4.查询设备
- (void)queryDeviceWithInfo:(DeviceInfo *)devInfo
{
tempDevInfo=devInfo;
if(!tempDevInfo)return;
//字典一
NSMutableDictionary *dic1 = [[NSMutableDictionaryalloc] init];
[dic1 setObject:@"FD00000102"forKey:@"ACCF23123456"];
// [dic1 setObject:@"FD00000102" forKey:[devInfo.mac uppercaseString]];
//字典二
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
[dic setObject:dic1 forKey:@"input"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic setObject:[NSNumbernumberWithInt:0] forKey:@"SN"];
[dic setObject:[NSNumbernumberWithInt:20021] forKey:@"CID"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.SID] forKey:@"SID"];
[dic setObject:@"DeviceSetReq"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:json,@"debug", nil];
NSURL *url = [self generateURL:DataBaseURL params:params];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=QueryDeviceRequest;
}
//将对象转换成json字符串
- (NSString *)changObjectToJsonString: (id)object{
NSData *tempData = [NSJSONSerialization dataWithJSONObject:object options:0 error:nil];
NSString *jsonString = [[NSStringalloc] initWithData:tempData encoding:NSUTF8StringEncoding];
return jsonString;
}
- (NSString *)URLEncodedString:(NSString *)string
{
NSString *result = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)string,
NULL,
CFSTR("!*'();:@&=+$,/?%#[]"),
kCFStringEncodingUTF8));
return result;
}
#pragma mark Request
- (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data
{
SBJsonParser *json=[[SBJsonParseralloc]init];
NSDictionary *dic=[json objectWithData:data];
if(!dic)
{
requestErrorNum++;
if(requestErrorNum==4)//超过3次请求失败
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:nilerrorType:currRequestType];
return;
}
}else
requestErrorNum=0;
if(currRequestType==SecurityCodeRequest)
{
if([[dic objectForKey:@"result"]integerValue]!=1)//请求失败则重新请求
{
[selfpostSecurityCodeWithRequest];
return;
}
[networkDatassetObject:dic forKey:[NSNumbernumberWithInt:SecurityCodeRequest]];
//注册用户
[selfresignWithRequest];
}
elseif(currRequestType==ResignRequest)//注册
{
if(!dic)//失败
{
[selfresignWithRequest];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
if(result==1)//成功
{
[[UserDataManagerinstance]insertOrUpdateUserData:regexUserData];
[self loginWithRequest];
}
else if(result==-104)//已经存在
{
[[UserDataManagerinstance]insertOrUpdateUserData:regexUserData];
[self loginWithRequest];//登录
}else if(result==-114)//以成功的方式处理
{
[[UserDataManagerinstance]insertOrUpdateUserData:regexUserData];
[self loginWithRequest];//登录
}
else
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:dic errorType:currRequestType];
}
}
elseif(currRequestType==LoginRequest)//登录
{
if(!dic)
{
[self loginWithRequest];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
if(result==1)//成功
{
regexUserData.userID=[[dic objectForKey:@"userId"]integerValue];
regexUserData.SID=[[dic objectForKey:@"SID"]integerValue];
if(delegete&&[delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
}else
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:dic errorType:currRequestType];
}
}
elseif(currRequestType==AddDeviceRequest)
{
if(!dic)
{
[selfaddDeviceWithRequest:tempDevInfo];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
switch (result) {
case -202://设备已经添加
case -15://设备在其他服务器
case 1://成功
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
// [self managerDeviceWithRequest:tempDevInfo isOpen:YES];
}
break;
default:
{
//不管是否添加成功,都执行
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
// if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
// [delegete DataRequestManager:self receiveData:dic errorType:currRequestType];
}
break;
}
}
elseif(currRequestType==ControlDeviceRequest)
{
if(!dic)
{
[selfmanagerDeviceWithRequest:controlDeviceArrayisOpen:sendControlDevState];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
if(result==1)//操作成功
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
}else
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:dic errorType:currRequestType];
}
}elseif(currRequestType==QueryDeviceRequest)
{
if(!dic)//如果返回失败则再次发送请求
{
[selfqueryDeviceWithInfo:tempDevInfo];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
if(result==1)//操作成功
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
}else
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:dic errorType:currRequestType];
}
}
}
//清理普通请求
-(void)clearOrdinaryRequest{
//清除之前,先清除队列之中的请求
// [self clearRequestInQueueWithArray];
if (ordinaryRequest) {
[ordinaryRequestclearDelegatesAndCancel];
ordinaryRequest=nil;
}
}
@end
3G数据请求的更多相关文章
- Ajax --- 数据请求
下面主要介绍(JS原生)数据请求的主要步骤: Ajax 数据请求步骤: 1.创建XMLHttpRequest对象 2.准备数据发送 3.执行发送 4.指定回掉函数 第一步:创建XMLHttpReque ...
- 携带cookie进行数据请求
前端进行数据请求有:普通的ajax(json)请求,jsop跨域请求,cors跨域请求,fetch请求...PC端这些请求方式中,普通的ajax(json)请求和jsop跨域请求是默认携带cookie ...
- XML 数据请求与JSON 数据请求
(1)XML 数据请求 使用 AFNetworking 中的 AFHTTPRequestOperation 和 AFXMLParserResponseSerializer,另外结合第三方框架 XMLD ...
- 使用 AFNetworking 进行 XML 和 JSON 数据请求
(1)XML 数据请求 使用 AFNetworking 中的 AFHTTPRequestOperation 和 AFXMLParserResponseSerializer,另外结合第三方框架 XMLD ...
- iOS - NetRequest 网络数据请求
1.网络请求 1.1 网络通讯三要素 1.IP 地址(主机名): 网络中设备的唯一标示.不易记忆,可以用主机名(域名). 1) IP V4: 0~255.0~255.0~255.0~255 ,共有 2 ...
- iOS开发——网络Swift篇&NSURL进行数据请求(POST与GET)
NSURL进行数据请求(POST与GET) 使用Swift进行iOS开发时,不可避免的要进行远程的数据获取和提交. 其数据请求的方式既可能是POST也可能是GET.同不管是POST还是GET又可以 ...
- ASP.NET问题处理---“数据请求超时错误“”
数据请求超时,一般有2中解决方式: 1.页面AJAX处理数据时延长时间: 2.后台数据库连接取数据时延长时间. 由于我的后台数据库连接取数据为循环读取数据,所以不存在超时问题,这里具体说说如何修改AJ ...
- VueJS搭建简单后台管理系统框架 (二) 模拟Ajax数据请求
开发过程中,免不了需要前台与后台的交互,大部分的交互都是通过Ajax请求来完成,在服务端未完成开发时,前端需要有一个可以模拟Ajax请求的服务器. 在NodeJs环境下,通过配置express可访问的 ...
- 微信小程序数据请求方法wx.request小测试
微信小程序数据请求方法 wx.request wxml文件: <view> <textarea value="{{textdata}}"/> </vi ...
随机推荐
- C# cmd执行命令
CMD命令执行 ///<summary> /// cmd命令执行,在cmd上可以执行的语句,直接传到这里,调用grads画图实例如下: /// Cmd(& ...
- linux操作系统基础
计算机概述 1.计算机接收用户输入指令数据,经过cpu数据与逻辑单元运算处理后,产生或储存成有用的信息--->I/O设备+cpu+处理信息=计算机. 2.计算机五大单元:I/O单元 内存单元 c ...
- c++读书笔记, 零散点滴的收获
1. 字节长度: short <= int <= long <= long long 2. wchar_t,最大扩展字符集合:char16_t.char32_t,unocide字符集 ...
- Delphi 中同类型方法的说明
对象的方法能定义成静态(static).虚拟(virtual).动态(dynamic)或消息处理(message).请看下面 的例子: TFoo = class procedure IAmAStati ...
- ASP.NET中Onclick和OnserverClick事件的区别
对于服务器按钮控件(即<asp:Button>类型的按钮): 服务器响应事件:OnClick 客户端响应属性:OnClientClick 对于html按钮控件(即<input typ ...
- c++学习笔记2
T: 1.默认实参只能声明一次: 设计含有默认实参的函数时,要合理设置形参的顺序 :局部变量不能作为默认实参 2.内联机制用于优化规模较小.流程直接.频繁调用的函数 3.constexpr函数 返 ...
- 6、Concurrent-Mark-Sweep
1.cms 主要用于年老代垃圾回收 2.这玩意牺牲通吐量换取最短垃圾回收时间 3.有的地方说是四个阶段,有的地方说五个阶段,还有六个阶段的,真相是----我也不知道 四个阶段: Initial mar ...
- ref与out之间的区别
ref和out都是C#中的关键字,所实现的功能也差不多,都是指定一个参数按照引用传递.对于编译后的程序而言,它们之间没有任何区别,也就是说它们只有语法区别. 总结起来,他们有如下语法区别: 1.ref ...
- [转] 使用反射机制控制Toast的显示时间
大体上说就是利用toast的内部类TN 来控制show和hide ,这是一个反射机制 怎么控制toast的显示时间呢?这个就是通过tn类的show和hide的方法 http://blog.csdn.n ...
- svn co
svn co 的用法经常有两种: 第一种: 直接 svn co http://svnserver/mypro/trunk 此时, 会在你的当前目录 ...