//
// AsyncSocket.h
//
// This class is in the public domain.
// Originally created by Dustin Voss on Wed Jan 29 2003.
// Updated and maintained by Deusty Designs and the Mac development community.
//
// http://code.google.com/p/cocoaasyncsocket/
//
#import <Foundation/Foundation.h>
@class AsyncSocket;
@class AsyncReadPacket;
@class AsyncWritePacket;
extern NSString *const AsyncSocketException;
extern NSString *const AsyncSocketErrorDomain;
enum AsyncSocketError
{
AsyncSocketCFSocketError = kCFSocketError, // From CFSocketError enum.
AsyncSocketNoError = 0, // Never used.
AsyncSocketCanceledError, // onSocketWillConnect: returned NO.
AsyncSocketConnectTimeoutError,
AsyncSocketReadMaxedOutError, // Reached set maxLength without completing
AsyncSocketReadTimeoutError,
AsyncSocketWriteTimeoutError
};
typedef enum AsyncSocketError AsyncSocketError;
@protocol AsyncSocketDelegate
@optional
/**
* In the event of an error, the socket is closed.
* You may call "unreadData" during this call-back to get the last bit of data off the socket.
* When connecting, this delegate method may be called
* before"onSocket:didAcceptNewSocket:" or "onSocket:didConnectToHost:".
**/
- (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err;
/**
* Called when a socket disconnects with or without error. If you want to release a socket after it disconnects,
* do so here. It is not safe to do that during "onSocket:willDisconnectWithError:".
*
* If you call the disconnect method, and the socket wasn't already disconnected,
* this delegate method will be called before the disconnect method returns.
**/
- (void)onSocketDidDisconnect:(AsyncSocket *)sock;
/**
* Called when a socket accepts a connection. Another socket is spawned to handle it. The new socket will have
* the same delegate and will call "onSocket:didConnectToHost:port:".
**/
- (void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket;
/**
* Called when a new socket is spawned to handle a connection. This method should return the run-loop of the
* thread on which the new socket and its delegate should operate. If omitted, [NSRunLoop currentRunLoop] is used.
**/
- (NSRunLoop *)onSocket:(AsyncSocket *)sock wantsRunLoopForNewSocket:(AsyncSocket *)newSocket;
/**
* Called when a socket is about to connect. This method should return YES to continue, or NO to abort.
* If aborted, will result in AsyncSocketCanceledError.
*
* If the connectToHost:onPort:error: method was called, the delegate will be able to access and configure the
* CFReadStream and CFWriteStream as desired prior to connection.
*
* If the connectToAddress:error: method was called, the delegate will be able to access and configure the
* CFSocket and CFSocketNativeHandle (BSD socket) as desired prior to connection. You will be able to access and
* configure the CFReadStream and CFWriteStream in the onSocket:didConnectToHost:port: method.
**/
- (BOOL)onSocketWillConnect:(AsyncSocket *)sock;
/**
* Called when a socket connects and is ready for reading and writing.
* The host parameter will be an IP address, not a DNS name.
**/
- (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port;
/**
* Called when a socket has completed reading the requested data into memory.
* Not called if there is an error.
**/
- (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag;
/**
* Called when a socket has read in data, but has not yet completed the read.
* This would occur if using readToData: or readToLength: methods.
* It may be used to for things such as updating progress bars.
**/
- (void)onSocket:(AsyncSocket *)sock didReadPartialDataOfLength:(NSUInteger)partialLength tag:(long)tag;
/**
* Called when a socket has completed writing the requested data. Not called if there is an error.
**/
- (void)onSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag;
/**
* Called when a socket has written some data, but has not yet completed the entire write.
* It may be used to for things such as updating progress bars.
**/
- (void)onSocket:(AsyncSocket *)sock didWritePartialDataOfLength:(NSUInteger)partialLength tag:(long)tag;
/**
* Called if a read operation has reached its timeout without completing.
* This method allows you to optionally extend the timeout.
* If you return a positive time interval (> 0) the read's timeout will be extended by the given amount.
* If you don't implement this method, or return a non-positive time interval (<= 0) the read will timeout as usual.
*
* The elapsed parameter is the sum of the original timeout, plus any additions previously added via this method.
* The length parameter is the number of bytes that have been read so far for the read operation.
*
* Note that this method may be called multiple times for a single read if you return positive numbers.
**/
- (NSTimeInterval)onSocket:(AsyncSocket *)sock
shouldTimeoutReadWithTag:(long)tag
elapsed:(NSTimeInterval)elapsed
bytesDone:(NSUInteger)length;
/**
* Called if a write operation has reached its timeout without completing.
* This method allows you to optionally extend the timeout.
* If you return a positive time interval (> 0) the write's timeout will be extended by the given amount.
* If you don't implement this method, or return a non-positive time interval (<= 0) the write will timeout as usual.
*
* The elapsed parameter is the sum of the original timeout, plus any additions previously added via this method.
* The length parameter is the number of bytes that have been written so far for the write operation.
*
* Note that this method may be called multiple times for a single write if you return positive numbers.
**/
- (NSTimeInterval)onSocket:(AsyncSocket *)sock
shouldTimeoutWriteWithTag:(long)tag
elapsed:(NSTimeInterval)elapsed
bytesDone:(NSUInteger)length;
/**
* Called after the socket has successfully completed SSL/TLS negotiation.
* This method is not called unless you use the provided startTLS method.
*
* If a SSL/TLS negotiation fails (invalid certificate, etc) then the socket will immediately close,
* and the onSocket:willDisconnectWithError: delegate method will be called with the specific SSL error code.
**/
- (void)onSocketDidSecure:(AsyncSocket *)sock;
@end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@interface AsyncSocket : NSObject
{
CFSocketNativeHandle theNativeSocket4;
CFSocketNativeHandle theNativeSocket6;
CFSocketRef theSocket4; // IPv4 accept or connect socket
CFSocketRef theSocket6; // IPv6 accept or connect socket
CFReadStreamRef theReadStream;
CFWriteStreamRef theWriteStream;
CFRunLoopSourceRef theSource4; // For theSocket4
CFRunLoopSourceRef theSource6; // For theSocket6
CFRunLoopRef theRunLoop;
CFSocketContext theContext;
NSArray *theRunLoopModes;
NSTimer *theConnectTimer;
NSMutableArray *theReadQueue;
AsyncReadPacket *theCurrentRead;
NSTimer *theReadTimer;
NSMutableData *partialReadBuffer;
NSMutableArray *theWriteQueue;
AsyncWritePacket *theCurrentWrite;
NSTimer *theWriteTimer;
id theDelegate;
UInt16 theFlags;
long theUserData;
}
- (id)init;
- (id)initWithDelegate:(id)delegate;
- (id)initWithDelegate:(id)delegate userData:(long)userData;
/* String representation is long but has no "\n". */
- (NSString *)description;
/**
* Use "canSafelySetDelegate" to see if there is any pending business (reads and writes) with the current delegate
* before changing it. It is, of course, safe to change the delegate before connecting or accepting connections.
**/
- (id)delegate;
- (BOOL)canSafelySetDelegate;
- (void)setDelegate:(
没有合适的资源?快使用搜索试试~ 我知道了~
一款塔防小游戏源码.zip
共288个文件
png:150个
h:64个
m:60个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 157 浏览量
2024-02-28
14:07:51
上传
评论
收藏 7.53MB ZIP 举报
温馨提示
1、该资源内项目代码经过严格调试,下载即用确保可以运行! 2、该资源适合计算机相关专业(如计科、人工智能、大数据、数学、电子信息等)正在做课程设计、期末大作业和毕设项目的学生、或者相关技术学习者作为学习资料参考使用。 3、该资源包括全部源码,需要具备一定基础才能看懂并调试代码。 1、该资源内项目代码经过严格调试,下载即用确保可以运行! 2、该资源适合计算机相关专业(如计科、人工智能、大数据、数学、电子信息等)正在做课程设计、期末大作业和毕设项目的学生、或者相关技术学习者作为学习资料参考使用。 3、该资源包括全部源码,需要具备一定基础才能看懂并调试代码。
资源推荐
资源详情
资源评论
收起资源包目录
一款塔防小游戏源码.zip (288个子文件)
libWeChatSDK.a 3.98MB
game.cfg 3KB
AsyncSocket.h 29KB
WXApiObject.h 17KB
AsyncUdpSocket.h 14KB
MBProgressHUD.h 12KB
AMPopTip.h 8KB
MapTemplates.h 7KB
Player.h 7KB
WXApi.h 5KB
ChrisTips.h 5KB
ChrisMonster.h 4KB
Reachability.h 4KB
Game.h 4KB
ChrisMap.h 4KB
ChrisTower.h 3KB
ChrisCannon.h 3KB
GameConfig.h 2KB
GameViewController.h 2KB
ChrisMapBox.h 2KB
GameBackGroundView.h 1KB
PlayerViewController.h 1KB
Level.h 1KB
ShopViewController.h 1KB
Home.h 1KB
IAPHelper.h 967B
LevelDisplayView.h 933B
WaveItem.h 908B
GameInfoView.h 861B
GoodsView.h 834B
Waves.h 809B
DateLimitObject.h 806B
UIViewController+SpecialScreenShot.h 790B
TimerControlRect.h 785B
ViewController.h 781B
PlayerBagItem.h 745B
LevelSelectViewController.h 733B
MapMakerViewController.h 702B
GameView.h 701B
Goods.h 673B
GameOpItemView.h 673B
DynamicTower.h 663B
DynamicLevel.h 642B
DynamicCannon.h 629B
DynamicMonster.h 627B
MapMakerView.h 534B
GoodsDetailView.h 518B
TowerMakerViewController.h 510B
ShareViewController.h 479B
CPMiscSupport.h 466B
PlayerBag.h 462B
MonsterMakerViewController.h 408B
CannonMakerViewController.h 407B
NSMutableDictionary+ChrisOperation.h 397B
GameMapView.h 395B
NSMutadbleArray+ChrisOperation.h 364B
NoteView.h 346B
ChrisMapPathItem.h 311B
AppDelegate.h 307B
InAppRageIAPHelper.h 297B
GameDefination.h 282B
HelpViewController.h 266B
DynamicProtocol.h 252B
FactoryViewController.h 222B
LevelSelectBGView.h 205B
MainView.h 188B
Contents.json 1KB
Contents.json 62B
Contents.json 62B
AsyncSocket.m 121KB
AsyncUdpSocket.m 63KB
ShopViewController.m 60KB
Player.m 32KB
GameViewController.m 31KB
AMPopTip.m 25KB
ChrisMap.m 24KB
MBProgressHUD.m 19KB
ChrisMonster.m 16KB
GameConfig.m 14KB
ChrisTower.m 14KB
Waves.m 14KB
Game.m 11KB
GameBackGroundView.m 10KB
ChrisCannon.m 10KB
PlayerViewController.m 9KB
Reachability.m 9KB
MapMakerViewController.m 9KB
LevelSelectViewController.m 8KB
LevelDisplayView.m 5KB
ViewController.m 5KB
IAPHelper.m 4KB
UIViewController+SpecialScreenShot.m 4KB
MapMakerView.m 4KB
GameInfoView.m 4KB
AppDelegate.m 4KB
Home.m 3KB
Level.m 3KB
ChrisMapBox.m 3KB
GoodsView.m 3KB
GoodsDetailView.m 3KB
共 288 条
- 1
- 2
- 3
资源评论
辣椒种子
- 粉丝: 4166
- 资源: 5822
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 进一步了解“学习 Spring Security”.zip
- 这是 Vue 2 的 repo 对于 Vue 3,请访问.zip
- 这个 repo 包含按频率排序的 10,000 个最常见的英语单词列表,由 Google 万亿词语料库的 n-gram 频率分析确定 .zip
- 软件版本控制可视化.zip
- 转至012345678.zip
- 设计模式Golang实现《研磨设计模式》读书笔记.zip
- 终极围棋学习指南.zip
- 用于读写 parquet 文件的纯 golang 库.zip
- 用于访问 Google API 的 PHP 客户端库.zip
- 用于 S3 兼容对象存储的 MinIO Go 客户端 SDK.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功