21 |
--------------------------------------------------------------------------------
/Source/GCD/Documentation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Welcome to the CocoaAsyncSocket project!
5 |
6 |
7 | A wealth of documentation can be found on the Google Code homepage:
8 | https://github.com/robbiehanson/CocoaAsyncSocket
9 |
10 |
11 |
12 | If you are new to networking, it is recommended you start by reading the Intro page:
13 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/Intro
14 |
15 |
16 |
17 | If you are a seasoned networking professional, with 10+ years of experience writing low-level socket code,
18 | and detailed knowledge of the underlying BSD networking stack, then you can skip the CommonPitfalls page.
19 | Otherwise, it should be considered mandatory reading:
20 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/CommonPitfalls
21 |
22 |
23 |
24 | A little bit of investment in your knowledge and understanding of networking fundamentals can go a long way.
25 | And it can save you a LOT of time and frustration in the long run.
26 |
27 |
28 |
29 | Your first goto for reference should ALWAYS be the header files. They are extremely well documented. Please read them.
30 |
31 |
32 |
33 | Did I mention you should read the headers? They're docemented very nicely, in plain english.
34 |
35 |
36 |
37 | If you have any questions you are welcome to post to the CocoaAsyncSocket mailing list:
38 | http://groups.google.com/group/cocoaasyncsocket
39 |
40 | The list is archived, and available for browsing online.
41 | You may be able to instantly find the answer you're looking for with a quick search.
42 |
43 |
44 | We hope the CocoaAsyncSocket project can provide you with powerful and easy to use networking libraries.
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Source/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Source/RunLoop/Documentation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Welcome to the CocoaAsyncSocket project!
5 |
6 |
7 | A wealth of documentation can be found on the Google Code homepage:
8 | https://github.com/robbiehanson/CocoaAsyncSocket
9 |
10 |
11 |
12 | If you are new to networking, it is recommended you start by reading the Intro page:
13 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/Intro
14 |
15 |
16 |
17 | If you are a seasoned networking professional, with 10+ years of experience writing low-level socket code,
18 | and detailed knowledge of the underlying BSD networking stack, then you can skip the CommonPitfalls page.
19 | Otherwise, it should be considered mandatory reading:
20 | https://github.com/robbiehanson/CocoaAsyncSocket/wiki/CommonPitfalls
21 |
22 |
23 |
24 | A little bit of investment in your knowledge and understanding of networking fundamentals can go a long way.
25 | And it can save you a LOT of time and frustration in the long run.
26 |
27 |
28 |
29 | Your first goto for reference should ALWAYS be the header files. They are extremely well documented. Please read them.
30 |
31 |
32 |
33 | Did I mention you should read the headers? They're docemented very nicely, in plain english.
34 |
35 |
36 |
37 | If you have any questions you are welcome to post to the CocoaAsyncSocket mailing list:
38 | http://groups.google.com/group/cocoaasyncsocket
39 |
40 | The list is archived, and available for browsing online.
41 | You may be able to instantly find the answer you're looking for with a quick search.
42 |
43 |
44 | We hope the CocoaAsyncSocket project can provide you with powerful and easy to use networking libraries.
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/DDASLLogger.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import "DDLog.h"
5 |
6 | /**
7 | * Welcome to Cocoa Lumberjack!
8 | *
9 | * The project page has a wealth of documentation if you have any questions.
10 | * https://github.com/CocoaLumberjack/CocoaLumberjack
11 | *
12 | * If you're new to the project you may wish to read the "Getting Started" wiki.
13 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
14 | *
15 | *
16 | * This class provides a logger for the Apple System Log facility.
17 | *
18 | * As described in the "Getting Started" page,
19 | * the traditional NSLog() function directs it's output to two places:
20 | *
21 | * - Apple System Log
22 | * - StdErr (if stderr is a TTY) so log statements show up in Xcode console
23 | *
24 | * To duplicate NSLog() functionality you can simply add this logger and a tty logger.
25 | * However, if you instead choose to use file logging (for faster performance),
26 | * you may choose to use a file logger and a tty logger.
27 | **/
28 |
29 | @interface DDASLLogger : DDAbstractLogger
30 | {
31 | aslclient client;
32 | }
33 |
34 | + (instancetype)sharedInstance;
35 |
36 | // Inherited from DDAbstractLogger
37 |
38 | // - (id )logFormatter;
39 | // - (void)setLogFormatter:(id )formatter;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/DDASLLogger.m:
--------------------------------------------------------------------------------
1 | #import "DDASLLogger.h"
2 |
3 | #import
4 |
5 | /**
6 | * Welcome to Cocoa Lumberjack!
7 | *
8 | * The project page has a wealth of documentation if you have any questions.
9 | * https://github.com/CocoaLumberjack/CocoaLumberjack
10 | *
11 | * If you're new to the project you may wish to read the "Getting Started" wiki.
12 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
13 | **/
14 |
15 | #if ! __has_feature(objc_arc)
16 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
17 | #endif
18 |
19 |
20 | @implementation DDASLLogger
21 |
22 | static DDASLLogger *sharedInstance;
23 |
24 | /**
25 | * The runtime sends initialize to each class in a program exactly one time just before the class,
26 | * or any class that inherits from it, is sent its first message from within the program. (Thus the
27 | * method may never be invoked if the class is not used.) The runtime sends the initialize message to
28 | * classes in a thread-safe manner. Superclasses receive this message before their subclasses.
29 | *
30 | * This method may also be called directly (assumably by accident), hence the safety mechanism.
31 | **/
32 | + (void)initialize
33 | {
34 | static BOOL initialized = NO;
35 | if (!initialized)
36 | {
37 | initialized = YES;
38 |
39 | sharedInstance = [[[self class] alloc] init];
40 | }
41 | }
42 |
43 | + (instancetype)sharedInstance
44 | {
45 | return sharedInstance;
46 | }
47 |
48 | - (id)init
49 | {
50 | if (sharedInstance != nil)
51 | {
52 | return nil;
53 | }
54 |
55 | if ((self = [super init]))
56 | {
57 | // A default asl client is provided for the main thread,
58 | // but background threads need to create their own client.
59 |
60 | client = asl_open(NULL, "com.apple.console", 0);
61 | }
62 | return self;
63 | }
64 |
65 | - (void)logMessage:(DDLogMessage *)logMessage
66 | {
67 | NSString *logMsg = logMessage->logMsg;
68 |
69 | if (formatter)
70 | {
71 | logMsg = [formatter formatLogMessage:logMessage];
72 | }
73 |
74 | if (logMsg)
75 | {
76 | const char *msg = [logMsg UTF8String];
77 |
78 | int aslLogLevel;
79 | switch (logMessage->logFlag)
80 | {
81 | // Note: By default ASL will filter anything above level 5 (Notice).
82 | // So our mappings shouldn't go above that level.
83 |
84 | case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_ALERT; break;
85 | case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_CRIT; break;
86 | case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_ERR; break;
87 | case LOG_FLAG_DEBUG : aslLogLevel = ASL_LEVEL_WARNING; break;
88 | default : aslLogLevel = ASL_LEVEL_NOTICE; break;
89 | }
90 |
91 | asl_log(client, NULL, aslLogLevel, "%s", msg);
92 | }
93 | }
94 |
95 | - (NSString *)loggerName
96 | {
97 | return @"cocoa.lumberjack.aslLogger";
98 | }
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "DDLog.h"
4 |
5 | /**
6 | * Welcome to Cocoa Lumberjack!
7 | *
8 | * The project page has a wealth of documentation if you have any questions.
9 | * https://github.com/CocoaLumberjack/CocoaLumberjack
10 | *
11 | * If you're new to the project you may wish to read the "Getting Started" wiki.
12 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
13 | *
14 | *
15 | * This class provides an abstract implementation of a database logger.
16 | *
17 | * That is, it provides the base implementation for a database logger to build atop of.
18 | * All that is needed for a concrete database logger is to extend this class
19 | * and override the methods in the implementation file that are prefixed with "db_".
20 | **/
21 |
22 | @interface DDAbstractDatabaseLogger : DDAbstractLogger {
23 | @protected
24 | NSUInteger saveThreshold;
25 | NSTimeInterval saveInterval;
26 | NSTimeInterval maxAge;
27 | NSTimeInterval deleteInterval;
28 | BOOL deleteOnEverySave;
29 |
30 | BOOL saveTimerSuspended;
31 | NSUInteger unsavedCount;
32 | dispatch_time_t unsavedTime;
33 | dispatch_source_t saveTimer;
34 | dispatch_time_t lastDeleteTime;
35 | dispatch_source_t deleteTimer;
36 | }
37 |
38 | /**
39 | * Specifies how often to save the data to disk.
40 | * Since saving is an expensive operation (disk io) it is not done after every log statement.
41 | * These properties allow you to configure how/when the logger saves to disk.
42 | *
43 | * A save is done when either (whichever happens first):
44 | *
45 | * - The number of unsaved log entries reaches saveThreshold
46 | * - The amount of time since the oldest unsaved log entry was created reaches saveInterval
47 | *
48 | * You can optionally disable the saveThreshold by setting it to zero.
49 | * If you disable the saveThreshold you are entirely dependent on the saveInterval.
50 | *
51 | * You can optionally disable the saveInterval by setting it to zero (or a negative value).
52 | * If you disable the saveInterval you are entirely dependent on the saveThreshold.
53 | *
54 | * It's not wise to disable both saveThreshold and saveInterval.
55 | *
56 | * The default saveThreshold is 500.
57 | * The default saveInterval is 60 seconds.
58 | **/
59 | @property (assign, readwrite) NSUInteger saveThreshold;
60 | @property (assign, readwrite) NSTimeInterval saveInterval;
61 |
62 | /**
63 | * It is likely you don't want the log entries to persist forever.
64 | * Doing so would allow the database to grow infinitely large over time.
65 | *
66 | * The maxAge property provides a way to specify how old a log statement can get
67 | * before it should get deleted from the database.
68 | *
69 | * The deleteInterval specifies how often to sweep for old log entries.
70 | * Since deleting is an expensive operation (disk io) is is done on a fixed interval.
71 | *
72 | * An alternative to the deleteInterval is the deleteOnEverySave option.
73 | * This specifies that old log entries should be deleted during every save operation.
74 | *
75 | * You can optionally disable the maxAge by setting it to zero (or a negative value).
76 | * If you disable the maxAge then old log statements are not deleted.
77 | *
78 | * You can optionally disable the deleteInterval by setting it to zero (or a negative value).
79 | *
80 | * If you disable both deleteInterval and deleteOnEverySave then old log statements are not deleted.
81 | *
82 | * It's not wise to enable both deleteInterval and deleteOnEverySave.
83 | *
84 | * The default maxAge is 7 days.
85 | * The default deleteInterval is 5 minutes.
86 | * The default deleteOnEverySave is NO.
87 | **/
88 | @property (assign, readwrite) NSTimeInterval maxAge;
89 | @property (assign, readwrite) NSTimeInterval deleteInterval;
90 | @property (assign, readwrite) BOOL deleteOnEverySave;
91 |
92 | /**
93 | * Forces a save of any pending log entries (flushes log entries to disk).
94 | **/
95 | - (void)savePendingLogEntries;
96 |
97 | /**
98 | * Removes any log entries that are older than maxAge.
99 | **/
100 | - (void)deleteOldLogEntries;
101 |
102 | @end
103 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/DDLog+LOGV.h:
--------------------------------------------------------------------------------
1 | //
2 | // DDLog+LOGV.h
3 | // Lumberjack
4 | //
5 | // Created by Mike Pontillo on 11/20/12.
6 | //
7 | //
8 |
9 | #ifndef Lumberjack_DDLog_LOGV_h
10 | #define Lumberjack_DDLog_LOGV_h
11 |
12 | #import "DDLog.h"
13 |
14 |
15 | #define LOGV_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, avalist) \
16 | [DDLog log:isAsynchronous \
17 | level:lvl \
18 | flag:flg \
19 | context:ctx \
20 | file:__FILE__ \
21 | function:fnct \
22 | line:__LINE__ \
23 | tag:atag \
24 | format:frmt \
25 | args:avalist]
26 |
27 | #define LOGV_OBJC_MACRO(async, lvl, flg, ctx, frmt, avalist) \
28 | LOGV_MACRO(async, lvl, flg, ctx, nil, sel_getName(_cmd), frmt, avalist)
29 |
30 | #define LOGV_C_MACRO(async, lvl, flg, ctx, frmt, avalist) \
31 | LOGV_MACRO(async, lvl, flg, ctx, nil, __FUNCTION__, frmt, avalist)
32 |
33 |
34 |
35 | #define SYNC_LOGV_OBJC_MACRO(lvl, flg, ctx, frmt, avalist) \
36 | LOGV_OBJC_MACRO( NO, lvl, flg, ctx, frmt, avalist)
37 |
38 | #define ASYNC_LOGV_OBJC_MACRO(lvl, flg, ctx, frmt, avalist) \
39 | LOGV_OBJC_MACRO(YES, lvl, flg, ctx, frmt, avalist)
40 |
41 | #define SYNC_LOGV_C_MACRO(lvl, flg, ctx, frmt, avalist) \
42 | LOGV_C_MACRO( NO, lvl, flg, ctx, frmt, avalist)
43 |
44 | #define ASYNC_LOGV_C_MACRO(lvl, flg, ctx, frmt, avalist) \
45 | LOGV_C_MACRO(YES, lvl, flg, ctx, frmt, avalist)
46 |
47 |
48 |
49 | #define LOGV_MAYBE(async, lvl, flg, ctx, fnct, frmt, avalist) \
50 | do { if(lvl & flg) LOGV_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, avalist); } while(0)
51 |
52 | #define LOGV_OBJC_MAYBE(async, lvl, flg, ctx, frmt, avalist) \
53 | LOGV_MAYBE(async, lvl, flg, ctx, sel_getName(_cmd), frmt, avalist)
54 |
55 | #define LOGV_C_MAYBE(async, lvl, flg, ctx, frmt, avalist) \
56 | LOGV_MAYBE(async, lvl, flg, ctx, __FUNCTION__, frmt, avalist)
57 |
58 | #define SYNC_LOGV_OBJC_MAYBE(lvl, flg, ctx, frmt, avalist) \
59 | LOGV_OBJC_MAYBE( NO, lvl, flg, ctx, frmt, avalist)
60 |
61 | #define ASYNC_LOGV_OBJC_MAYBE(lvl, flg, ctx, frmt, avalist) \
62 | LOGV_OBJC_MAYBE(YES, lvl, flg, ctx, frmt, avalist)
63 |
64 | #define SYNC_LOGV_C_MAYBE(lvl, flg, ctx, frmt, avalist) \
65 | LOGV_C_MAYBE( NO, lvl, flg, ctx, frmt, avalist)
66 |
67 | #define ASYNC_LOGV_C_MAYBE(lvl, flg, ctx, frmt, avalist) \
68 | LOGV_C_MAYBE(YES, lvl, flg, ctx, frmt, avalist)
69 |
70 |
71 |
72 | #define LOGV_OBJC_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, avalist) \
73 | LOGV_MACRO(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, avalist)
74 |
75 | #define LOGV_C_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, avalist) \
76 | LOGV_MACRO(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, avalist)
77 |
78 | #define LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, avalist) \
79 | do { if(lvl & flg) LOGV_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, avalist); } while(0)
80 |
81 | #define LOGV_OBJC_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, avalist) \
82 | LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, avalist)
83 |
84 | #define LOGV_C_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, avalist) \
85 | LOGV_TAG_MAYBE(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, avalist)
86 |
87 |
88 |
89 | #define DDLogvError(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, avalist)
90 | #define DDLogvWarn(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, avalist)
91 | #define DDLogvInfo(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, avalist)
92 | #define DDLogvVerbose(frmt, avalist) LOGV_OBJC_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, avalist)
93 |
94 | #define DDLogvCError(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, avalist)
95 | #define DDLogvCWarn(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, avalist)
96 | #define DDLogvCInfo(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, avalist)
97 | #define DDLogvCVerbose(frmt, avalist) LOGV_C_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, avalist)
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/Extensions/DDContextFilterLogFormatter.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "DDLog.h"
3 |
4 | /**
5 | * Welcome to Cocoa Lumberjack!
6 | *
7 | * The project page has a wealth of documentation if you have any questions.
8 | * https://github.com/CocoaLumberjack/CocoaLumberjack
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" page.
11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
12 | *
13 | *
14 | * This class provides a log formatter that filters log statements from a logging context not on the whitelist.
15 | *
16 | * A log formatter can be added to any logger to format and/or filter its output.
17 | * You can learn more about log formatters here:
18 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
19 | *
20 | * You can learn more about logging context's here:
21 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomContext
22 | *
23 | * But here's a quick overview / refresher:
24 | *
25 | * Every log statement has a logging context.
26 | * These come from the underlying logging macros defined in DDLog.h.
27 | * The default logging context is zero.
28 | * You can define multiple logging context's for use in your application.
29 | * For example, logically separate parts of your app each have a different logging context.
30 | * Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context.
31 | **/
32 | @interface DDContextWhitelistFilterLogFormatter : NSObject
33 |
34 | - (id)init;
35 |
36 | - (void)addToWhitelist:(int)loggingContext;
37 | - (void)removeFromWhitelist:(int)loggingContext;
38 |
39 | - (NSArray *)whitelist;
40 |
41 | - (BOOL)isOnWhitelist:(int)loggingContext;
42 |
43 | @end
44 |
45 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
46 | #pragma mark -
47 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48 |
49 | /**
50 | * This class provides a log formatter that filters log statements from a logging context on the blacklist.
51 | **/
52 | @interface DDContextBlacklistFilterLogFormatter : NSObject
53 |
54 | - (id)init;
55 |
56 | - (void)addToBlacklist:(int)loggingContext;
57 | - (void)removeFromBlacklist:(int)loggingContext;
58 |
59 | - (NSArray *)blacklist;
60 |
61 | - (BOOL)isOnBlacklist:(int)loggingContext;
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/Extensions/DDContextFilterLogFormatter.m:
--------------------------------------------------------------------------------
1 | #import "DDContextFilterLogFormatter.h"
2 | #import
3 |
4 | /**
5 | * Welcome to Cocoa Lumberjack!
6 | *
7 | * The project page has a wealth of documentation if you have any questions.
8 | * https://github.com/CocoaLumberjack/CocoaLumberjack
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" wiki.
11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
12 | **/
13 |
14 | #if ! __has_feature(objc_arc)
15 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
16 | #endif
17 |
18 | @interface DDLoggingContextSet : NSObject
19 |
20 | - (void)addToSet:(int)loggingContext;
21 | - (void)removeFromSet:(int)loggingContext;
22 |
23 | - (NSArray *)currentSet;
24 |
25 | - (BOOL)isInSet:(int)loggingContext;
26 |
27 | @end
28 |
29 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
30 | #pragma mark -
31 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
32 |
33 | @implementation DDContextWhitelistFilterLogFormatter
34 | {
35 | DDLoggingContextSet *contextSet;
36 | }
37 |
38 | - (id)init
39 | {
40 | if ((self = [super init]))
41 | {
42 | contextSet = [[DDLoggingContextSet alloc] init];
43 | }
44 | return self;
45 | }
46 |
47 |
48 | - (void)addToWhitelist:(int)loggingContext
49 | {
50 | [contextSet addToSet:loggingContext];
51 | }
52 |
53 | - (void)removeFromWhitelist:(int)loggingContext
54 | {
55 | [contextSet removeFromSet:loggingContext];
56 | }
57 |
58 | - (NSArray *)whitelist
59 | {
60 | return [contextSet currentSet];
61 | }
62 |
63 | - (BOOL)isOnWhitelist:(int)loggingContext
64 | {
65 | return [contextSet isInSet:loggingContext];
66 | }
67 |
68 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage
69 | {
70 | if ([self isOnWhitelist:logMessage->logContext])
71 | return logMessage->logMsg;
72 | else
73 | return nil;
74 | }
75 |
76 | @end
77 |
78 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
79 | #pragma mark -
80 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
81 |
82 | @implementation DDContextBlacklistFilterLogFormatter
83 | {
84 | DDLoggingContextSet *contextSet;
85 | }
86 |
87 | - (id)init
88 | {
89 | if ((self = [super init]))
90 | {
91 | contextSet = [[DDLoggingContextSet alloc] init];
92 | }
93 | return self;
94 | }
95 |
96 |
97 | - (void)addToBlacklist:(int)loggingContext
98 | {
99 | [contextSet addToSet:loggingContext];
100 | }
101 |
102 | - (void)removeFromBlacklist:(int)loggingContext
103 | {
104 | [contextSet removeFromSet:loggingContext];
105 | }
106 |
107 | - (NSArray *)blacklist
108 | {
109 | return [contextSet currentSet];
110 | }
111 |
112 | - (BOOL)isOnBlacklist:(int)loggingContext
113 | {
114 | return [contextSet isInSet:loggingContext];
115 | }
116 |
117 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage
118 | {
119 | if ([self isOnBlacklist:logMessage->logContext])
120 | return nil;
121 | else
122 | return logMessage->logMsg;
123 | }
124 |
125 | @end
126 |
127 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
128 | #pragma mark -
129 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
130 |
131 | @implementation DDLoggingContextSet
132 | {
133 | OSSpinLock lock;
134 | NSMutableSet *set;
135 | }
136 |
137 | - (id)init
138 | {
139 | if ((self = [super init]))
140 | {
141 | set = [[NSMutableSet alloc] init];
142 | }
143 | return self;
144 | }
145 |
146 |
147 | - (void)addToSet:(int)loggingContext
148 | {
149 | OSSpinLockLock(&lock);
150 | {
151 | [set addObject:@(loggingContext)];
152 | }
153 | OSSpinLockUnlock(&lock);
154 | }
155 |
156 | - (void)removeFromSet:(int)loggingContext
157 | {
158 | OSSpinLockLock(&lock);
159 | {
160 | [set removeObject:@(loggingContext)];
161 | }
162 | OSSpinLockUnlock(&lock);
163 | }
164 |
165 | - (NSArray *)currentSet
166 | {
167 | NSArray *result = nil;
168 |
169 | OSSpinLockLock(&lock);
170 | {
171 | result = [set allObjects];
172 | }
173 | OSSpinLockUnlock(&lock);
174 |
175 | return result;
176 | }
177 |
178 | - (BOOL)isInSet:(int)loggingContext
179 | {
180 | BOOL result = NO;
181 |
182 | OSSpinLockLock(&lock);
183 | {
184 | result = [set containsObject:@(loggingContext)];
185 | }
186 | OSSpinLockUnlock(&lock);
187 |
188 | return result;
189 | }
190 |
191 | @end
192 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/Extensions/DDDispatchQueueLogFormatter.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "DDLog.h"
4 |
5 |
6 | /**
7 | * Welcome to Cocoa Lumberjack!
8 | *
9 | * The project page has a wealth of documentation if you have any questions.
10 | * https://github.com/CocoaLumberjack/CocoaLumberjack
11 | *
12 | * If you're new to the project you may wish to read the "Getting Started" page.
13 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
14 | *
15 | *
16 | * This class provides a log formatter that prints the dispatch_queue label instead of the mach_thread_id.
17 | *
18 | * A log formatter can be added to any logger to format and/or filter its output.
19 | * You can learn more about log formatters here:
20 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
21 | *
22 | * A typical NSLog (or DDTTYLogger) prints detailed info as [:].
23 | * For example:
24 | *
25 | * 2011-10-17 20:21:45.435 AppName[19928:5207] Your log message here
26 | *
27 | * Where:
28 | * - 19928 = process id
29 | * - 5207 = thread id (mach_thread_id printed in hex)
30 | *
31 | * When using grand central dispatch (GCD), this information is less useful.
32 | * This is because a single serial dispatch queue may be run on any thread from an internally managed thread pool.
33 | * For example:
34 | *
35 | * 2011-10-17 20:32:31.111 AppName[19954:4d07] Message from my_serial_dispatch_queue
36 | * 2011-10-17 20:32:31.112 AppName[19954:5207] Message from my_serial_dispatch_queue
37 | * 2011-10-17 20:32:31.113 AppName[19954:2c55] Message from my_serial_dispatch_queue
38 | *
39 | * This formatter allows you to replace the standard [box:info] with the dispatch_queue name.
40 | * For example:
41 | *
42 | * 2011-10-17 20:32:31.111 AppName[img-scaling] Message from my_serial_dispatch_queue
43 | * 2011-10-17 20:32:31.112 AppName[img-scaling] Message from my_serial_dispatch_queue
44 | * 2011-10-17 20:32:31.113 AppName[img-scaling] Message from my_serial_dispatch_queue
45 | *
46 | * If the dispatch_queue doesn't have a set name, then it falls back to the thread name.
47 | * If the current thread doesn't have a set name, then it falls back to the mach_thread_id in hex (like normal).
48 | *
49 | * Note: If manually creating your own background threads (via NSThread/alloc/init or NSThread/detachNeThread),
50 | * you can use [[NSThread currentThread] setName:(NSString *)].
51 | **/
52 | @interface DDDispatchQueueLogFormatter : NSObject {
53 | @protected
54 |
55 | NSString *dateFormatString;
56 | }
57 |
58 | /**
59 | * Standard init method.
60 | * Configure using properties as desired.
61 | **/
62 | - (id)init;
63 |
64 | /**
65 | * The minQueueLength restricts the minimum size of the [detail box].
66 | * If the minQueueLength is set to 0, there is no restriction.
67 | *
68 | * For example, say a dispatch_queue has a label of "diskIO":
69 | *
70 | * If the minQueueLength is 0: [diskIO]
71 | * If the minQueueLength is 4: [diskIO]
72 | * If the minQueueLength is 5: [diskIO]
73 | * If the minQueueLength is 6: [diskIO]
74 | * If the minQueueLength is 7: [diskIO ]
75 | * If the minQueueLength is 8: [diskIO ]
76 | *
77 | * The default minQueueLength is 0 (no minimum, so [detail box] won't be padded).
78 | *
79 | * If you want every [detail box] to have the exact same width,
80 | * set both minQueueLength and maxQueueLength to the same value.
81 | **/
82 | @property (assign) NSUInteger minQueueLength;
83 |
84 | /**
85 | * The maxQueueLength restricts the number of characters that will be inside the [detail box].
86 | * If the maxQueueLength is 0, there is no restriction.
87 | *
88 | * For example, say a dispatch_queue has a label of "diskIO":
89 | *
90 | * If the maxQueueLength is 0: [diskIO]
91 | * If the maxQueueLength is 4: [disk]
92 | * If the maxQueueLength is 5: [diskI]
93 | * If the maxQueueLength is 6: [diskIO]
94 | * If the maxQueueLength is 7: [diskIO]
95 | * If the maxQueueLength is 8: [diskIO]
96 | *
97 | * The default maxQueueLength is 0 (no maximum, so [detail box] won't be truncated).
98 | *
99 | * If you want every [detail box] to have the exact same width,
100 | * set both minQueueLength and maxQueueLength to the same value.
101 | **/
102 | @property (assign) NSUInteger maxQueueLength;
103 |
104 | /**
105 | * Sometimes queue labels have long names like "com.apple.main-queue",
106 | * but you'd prefer something shorter like simply "main".
107 | *
108 | * This method allows you to set such preferred replacements.
109 | * The above example is set by default.
110 | *
111 | * To remove/undo a previous replacement, invoke this method with nil for the 'shortLabel' parameter.
112 | **/
113 | - (NSString *)replacementStringForQueueLabel:(NSString *)longLabel;
114 | - (void)setReplacementString:(NSString *)shortLabel forQueueLabel:(NSString *)longLabel;
115 |
116 | @end
117 |
118 | /**
119 | * Method declarations that make it easier to extend/modify DDDispatchQueueLogFormatter
120 | **/
121 | @interface DDDispatchQueueLogFormatter (OverridableMethods)
122 |
123 | - (NSString *)stringFromDate:(NSDate *)date;
124 | - (NSString *)queueThreadLabelForLogMessage:(DDLogMessage *)logMessage;
125 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage;
126 |
127 | @end
128 |
129 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/Extensions/DDMultiFormatter.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "DDLog.h"
3 |
4 | /**
5 | * Welcome to Cocoa Lumberjack!
6 | *
7 | * The project page has a wealth of documentation if you have any questions.
8 | * https://github.com/CocoaLumberjack/CocoaLumberjack
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" page.
11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
12 | *
13 | *
14 | * This formatter can be used to chain different formatters together.
15 | * The log message will processed in the order of the formatters added.
16 | **/
17 |
18 | @interface DDMultiFormatter : NSObject
19 |
20 | /**
21 | * Array of chained formatters
22 | */
23 | @property (readonly) NSArray *formatters;
24 |
25 | - (void)addFormatter:(id)formatter;
26 | - (void)removeFormatter:(id)formatter;
27 | - (void)removeAllFormatters;
28 | - (BOOL)isFormattingWithFormatter:(id)formatter;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/Extensions/DDMultiFormatter.m:
--------------------------------------------------------------------------------
1 | #import "DDMultiFormatter.h"
2 |
3 | /**
4 | * Welcome to Cocoa Lumberjack!
5 | *
6 | * The project page has a wealth of documentation if you have any questions.
7 | * https://github.com/CocoaLumberjack/CocoaLumberjack
8 | *
9 | * If you're new to the project you may wish to read the "Getting Started" page.
10 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
11 | **/
12 |
13 | #if TARGET_OS_IPHONE
14 | // Compiling for iOS
15 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
16 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0
17 | #else // iOS 5.X or earlier
18 | #define NEEDS_DISPATCH_RETAIN_RELEASE 1
19 | #endif
20 | #else
21 | // Compiling for Mac OS X
22 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
23 | #define NEEDS_DISPATCH_RETAIN_RELEASE 0
24 | #else // Mac OS X 10.7 or earlier
25 | #define NEEDS_DISPATCH_RETAIN_RELEASE 1
26 | #endif
27 | #endif
28 |
29 |
30 | @interface DDMultiFormatter ()
31 |
32 | - (DDLogMessage *)logMessageForLine:(NSString *)line originalMessage:(DDLogMessage *)message;
33 |
34 | @end
35 |
36 |
37 | @implementation DDMultiFormatter {
38 | dispatch_queue_t _queue;
39 | NSMutableArray *_formatters;
40 | }
41 |
42 | - (id)init {
43 | self = [super init];
44 | if (self) {
45 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
46 | _queue = dispatch_queue_create("cocoa.lumberjack.multiformatter", DISPATCH_QUEUE_CONCURRENT);
47 | #else
48 | _queue = dispatch_queue_create("cocoa.lumberjack.multiformatter", NULL);
49 | #endif
50 | _formatters = [NSMutableArray new];
51 | }
52 |
53 | return self;
54 | }
55 |
56 | #if NEEDS_DISPATCH_RETAIN_RELEASE
57 | - (void)dealloc {
58 | dispatch_release(_queue);
59 | }
60 | #endif
61 |
62 | #pragma mark Processing
63 |
64 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage {
65 | __block NSString *line = logMessage->logMsg;
66 |
67 | dispatch_sync(_queue, ^{
68 | for (id formatter in _formatters) {
69 | DDLogMessage *message = [self logMessageForLine:line originalMessage:logMessage];
70 | line = [formatter formatLogMessage:message];
71 |
72 | if (!line) {
73 | break;
74 | }
75 | }
76 | });
77 |
78 | return line;
79 | }
80 |
81 | - (DDLogMessage *)logMessageForLine:(NSString *)line originalMessage:(DDLogMessage *)message {
82 | DDLogMessage *newMessage = [message copy];
83 | newMessage->logMsg = line;
84 | return newMessage;
85 | }
86 |
87 | #pragma mark Formatters
88 |
89 | - (NSArray *)formatters {
90 | __block NSArray *formatters;
91 |
92 | dispatch_sync(_queue, ^{
93 | formatters = [_formatters copy];
94 | });
95 |
96 | return formatters;
97 | }
98 |
99 | - (void)addFormatter:(id)formatter {
100 | dispatch_barrier_async(_queue, ^{
101 | [_formatters addObject:formatter];
102 | });
103 | }
104 |
105 | - (void)removeFormatter:(id)formatter {
106 | dispatch_barrier_async(_queue, ^{
107 | [_formatters removeObject:formatter];
108 | });
109 | }
110 |
111 | - (void)removeAllFormatters {
112 | dispatch_barrier_async(_queue, ^{
113 | [_formatters removeAllObjects];
114 | });
115 | }
116 |
117 | - (BOOL)isFormattingWithFormatter:(id)formatter {
118 | __block BOOL hasFormatter;
119 |
120 | dispatch_sync(_queue, ^{
121 | hasFormatter = [_formatters containsObject:formatter];
122 | });
123 |
124 | return hasFormatter;
125 | }
126 |
127 | @end
128 |
--------------------------------------------------------------------------------
/Source/Vendor/CocoaLumberjack/Extensions/README.txt:
--------------------------------------------------------------------------------
1 | This folder contains some sample formatters that may be helpful.
2 |
3 | Feel free to change them, extend them, or use them as the basis for your own custom formatter(s).
4 |
5 | More information about creating your own custom formatters can be found on the wiki:
6 | https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
7 |
8 |
--------------------------------------------------------------------------------
/Tests/Mac/CocoaAsyncSocket.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Tests/Mac/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/CocoaAsyncSocketTestsMac.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/Tests/Mac/CocoaAsyncSocket.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Tests/Mac/GCDAsyncSocketUNTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // GCDAsyncSocketConnectionTests.m
3 | // GCDAsyncSocketConnectionTests
4 | //
5 | // Created by Christopher Ballinger on 10/31/14.
6 | //
7 | //
8 |
9 | #import
10 | #import
11 | @import CocoaAsyncSocket;
12 |
13 | @interface GCDAsyncSocketUNTests : XCTestCase
14 | @property (nonatomic, strong) NSURL *url;
15 | @property (nonatomic, strong) GCDAsyncSocket *clientSocket;
16 | @property (nonatomic, strong) GCDAsyncSocket *serverSocket;
17 | @property (nonatomic, strong) GCDAsyncSocket *acceptedServerSocket;
18 | @property (nonatomic, strong) NSData *readData;
19 |
20 | @property (nonatomic, strong) XCTestExpectation *expectation;
21 | @end
22 |
23 | @implementation GCDAsyncSocketUNTests
24 |
25 | - (void)setUp {
26 | [super setUp];
27 | // Put setup code here. This method is called before the invocation of each test method in the class.
28 | self.url = [NSURL fileURLWithPath:@"/tmp/GCDAsyncSocketUNTests"];
29 | self.clientSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
30 | self.serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
31 | }
32 |
33 | - (void)tearDown {
34 | // Put teardown code here. This method is called after the invocation of each test method in the class.
35 | [super tearDown];
36 | [self.clientSocket disconnect];
37 | [self.serverSocket disconnect];
38 | [self.acceptedServerSocket disconnect];
39 | self.clientSocket = nil;
40 | self.serverSocket = nil;
41 | self.acceptedServerSocket = nil;
42 | [[NSFileManager defaultManager] removeItemAtURL:self.url error:nil];
43 | }
44 |
45 | - (void)testFullConnection {
46 | NSError *error = nil;
47 | BOOL success = NO;
48 | success = [self.serverSocket acceptOnUrl:self.url error:&error];
49 | XCTAssertTrue(success, @"Server failed setting up socket at path %@ %@", self.url.path, error);
50 | success = [self.clientSocket connectToUrl:self.url withTimeout:-1 error:&error];
51 | XCTAssertTrue(success, @"Client failed connecting to server socket at path %@ %@", self.url.path, error);
52 |
53 | self.expectation = [self expectationWithDescription:@"Test Full Connection"];
54 | [self waitForExpectationsWithTimeout:30 handler:^(NSError *error) {
55 | if (error) {
56 | NSLog(@"Error establishing test connection");
57 | }
58 | }];
59 | }
60 |
61 | /**** BROKEN TESTS *******
62 |
63 |
64 | - (void)testTransferFromClient {
65 |
66 | NSData *testData = [@"ThisTestRocks!!!" dataUsingEncoding:NSUTF8StringEncoding];
67 |
68 | // set up and conncet to socket
69 | [self.serverSocket acceptOnUrl:self.url error:nil];
70 | [self.clientSocket connectToUrl:self.url withTimeout:-1 error:nil];
71 |
72 | // wait for connection
73 | self.expectation = [self expectationWithDescription:@"Socket Connected"];
74 | [self waitForExpectationsWithTimeout:30 handler:^(NSError *error) {
75 |
76 | // start reading
77 | [self.acceptedServerSocket readDataWithTimeout:-1 tag:0];
78 |
79 | // send data
80 | self.expectation = [self expectationWithDescription:@"Data Sent"];
81 | [self.clientSocket writeData:testData withTimeout:-1 tag:0];
82 | [self waitForExpectationsWithTimeout:1 handler:^(NSError *error) {
83 | if (error) {
84 | return NSLog(@"Error reading data");
85 | }
86 | XCTAssertTrue([testData isEqual:self.readData], @"Read data did not match test data");
87 | }];
88 | }];
89 | }
90 |
91 | - (void)testTransferFromServer {
92 |
93 | NSData *testData = [@"ThisTestRocks!!!" dataUsingEncoding:NSUTF8StringEncoding];
94 |
95 | // set up and conncet to socket
96 | [self.serverSocket acceptOnUrl:self.url error:nil];
97 | [self.clientSocket connectToUrl:self.url withTimeout:-1 error:nil];
98 |
99 | // wait for connection
100 | self.expectation = [self expectationWithDescription:@"Socket Connected"];
101 | [self waitForExpectationsWithTimeout:30 handler:^(NSError *error) {
102 |
103 | // start reading
104 | [self.clientSocket readDataWithTimeout:-1 tag:0];
105 |
106 | // send data
107 | self.expectation = [self expectationWithDescription:@"Data Sent"];
108 | [self.acceptedServerSocket writeData:testData withTimeout:-1 tag:0];
109 | [self waitForExpectationsWithTimeout:1 handler:^(NSError *error) {
110 | if (error) {
111 | return NSLog(@"Error reading data");
112 | }
113 | XCTAssertTrue([testData isEqual:self.readData], @"Read data did not match test data");
114 | }];
115 | }];
116 | }
117 |
118 | **************/
119 |
120 | #pragma mark GCDAsyncSocketDelegate methods
121 |
122 | /**
123 | * Called when a socket accepts a connection.
124 | * Another socket is automatically spawned to handle it.
125 | *
126 | * You must retain the newSocket if you wish to handle the connection.
127 | * Otherwise the newSocket instance will be released and the spawned connection will be closed.
128 | *
129 | * By default the new socket will have the same delegate and delegateQueue.
130 | * You may, of course, change this at any time.
131 | **/
132 | - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket {
133 | NSLog(@"didAcceptNewSocket %@ %@", sock, newSocket);
134 | self.acceptedServerSocket = newSocket;
135 | }
136 |
137 | /**
138 | * Called when a socket connects and is ready for reading and writing.
139 | * The host parameter will be an IP address, not a DNS name.
140 | **/
141 | - (void)socket:(GCDAsyncSocket *)sock didConnectToUrl:(NSURL *)url {
142 | NSLog(@"didConnectToUrl %@", url);
143 | [self.expectation fulfill];
144 | }
145 |
146 | /**
147 | * Called when a socket has completed reading the requested data into memory.
148 | * Not called if there is an error.
149 | **/
150 | - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag {
151 | NSLog(@"didReadData: %@ tag: %ld", data, tag);
152 | self.readData = data;
153 | [self.expectation fulfill];
154 | }
155 |
156 |
157 | @end
158 |
--------------------------------------------------------------------------------
/Tests/Mac/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.chrisballinger.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Tests/Mac/Podfile:
--------------------------------------------------------------------------------
1 | source 'https://github.com/CocoaPods/Specs.git'
2 |
3 | use_frameworks!
4 |
5 | target :CocoaAsyncSocketTestsMac do
6 | platform :osx, '10.8'
7 | pod 'CocoaAsyncSocket', :path => '../../CocoaAsyncSocket.podspec'
8 | end
--------------------------------------------------------------------------------
/Tests/Mac/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - CocoaAsyncSocket (7.4.2):
3 | - CocoaAsyncSocket/All (= 7.4.2)
4 | - CocoaAsyncSocket/All (7.4.2):
5 | - CocoaAsyncSocket/GCD
6 | - CocoaAsyncSocket/RunLoop
7 | - CocoaAsyncSocket/GCD (7.4.2)
8 | - CocoaAsyncSocket/RunLoop (7.4.2)
9 |
10 | DEPENDENCIES:
11 | - CocoaAsyncSocket (from `../../CocoaAsyncSocket.podspec`)
12 |
13 | EXTERNAL SOURCES:
14 | CocoaAsyncSocket:
15 | :path: "../../CocoaAsyncSocket.podspec"
16 |
17 | SPEC CHECKSUMS:
18 | CocoaAsyncSocket: ea27dc2477a5e83223ca93531ad4508180744c35
19 |
20 | COCOAPODS: 0.39.0
21 |
--------------------------------------------------------------------------------
/Tests/Shared/GCDAsyncSocketConnectionTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // GCDAsyncSocketConnectionTests.m
3 | // GCDAsyncSocketConnectionTests
4 | //
5 | // Created by Christopher Ballinger on 10/31/14.
6 | //
7 | //
8 |
9 | #import
10 | #import
11 | @import CocoaAsyncSocket;
12 |
13 | static const uint16_t kTestPort = 30301;
14 |
15 | @interface GCDAsyncSocketConnectionTests : XCTestCase
16 | @property (nonatomic, strong) GCDAsyncSocket *clientSocket;
17 | @property (nonatomic, strong) GCDAsyncSocket *serverSocket;
18 | @property (nonatomic, strong) GCDAsyncSocket *acceptedServerSocket;
19 |
20 | @property (nonatomic, strong) XCTestExpectation *expectation;
21 | @end
22 |
23 | @implementation GCDAsyncSocketConnectionTests
24 |
25 | - (void)setUp {
26 | [super setUp];
27 | // Put setup code here. This method is called before the invocation of each test method in the class.
28 | self.clientSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
29 | self.serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
30 | }
31 |
32 | - (void)tearDown {
33 | // Put teardown code here. This method is called after the invocation of each test method in the class.
34 | [super tearDown];
35 | [self.clientSocket disconnect];
36 | [self.serverSocket disconnect];
37 | [self.acceptedServerSocket disconnect];
38 | self.clientSocket = nil;
39 | self.serverSocket = nil;
40 | self.acceptedServerSocket = nil;
41 | }
42 |
43 | - (void)testFullConnection {
44 | NSError *error = nil;
45 | BOOL success = NO;
46 | success = [self.serverSocket acceptOnPort:kTestPort error:&error];
47 | XCTAssertTrue(success, @"Server failed setting up socket on port %d %@", kTestPort, error);
48 | success = [self.clientSocket connectToHost:@"127.0.0.1" onPort:kTestPort error:&error];
49 | XCTAssertTrue(success, @"Client failed connecting to up server socket on port %d %@", kTestPort, error);
50 |
51 | self.expectation = [self expectationWithDescription:@"Test Full Connection"];
52 | [self waitForExpectationsWithTimeout:30 handler:^(NSError *error) {
53 | if (error) {
54 | NSLog(@"Error establishing test connection");
55 | }
56 | }];
57 | }
58 |
59 | #pragma mark GCDAsyncSocketDelegate methods
60 |
61 | /**
62 | * Called when a socket accepts a connection.
63 | * Another socket is automatically spawned to handle it.
64 | *
65 | * You must retain the newSocket if you wish to handle the connection.
66 | * Otherwise the newSocket instance will be released and the spawned connection will be closed.
67 | *
68 | * By default the new socket will have the same delegate and delegateQueue.
69 | * You may, of course, change this at any time.
70 | **/
71 | - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket {
72 | NSLog(@"didAcceptNewSocket %@ %@", sock, newSocket);
73 | self.acceptedServerSocket = newSocket;
74 | }
75 |
76 | /**
77 | * Called when a socket connects and is ready for reading and writing.
78 | * The host parameter will be an IP address, not a DNS name.
79 | **/
80 | - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
81 | NSLog(@"didConnectToHost %@ %@ %d", sock, host, port);
82 | [self.expectation fulfill];
83 | }
84 |
85 |
86 | @end
87 |
--------------------------------------------------------------------------------
/Tests/Shared/SwiftTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SwiftTests.swift
3 | // CocoaAsyncSocket
4 | //
5 | // Created by Chris Ballinger on 2/17/16.
6 | //
7 | //
8 |
9 | import XCTest
10 | import CocoaAsyncSocket
11 |
12 | class SwiftTests: XCTestCase, GCDAsyncSocketDelegate {
13 |
14 | let kTestPort: UInt16 = 30301
15 |
16 | var clientSocket: GCDAsyncSocket?
17 | var serverSocket: GCDAsyncSocket?
18 | var acceptedServerSocket: GCDAsyncSocket?
19 | var expectation: XCTestExpectation?
20 |
21 | override func setUp() {
22 | super.setUp()
23 | // Put setup code here. This method is called before the invocation of each test method in the class.
24 | clientSocket = GCDAsyncSocket(delegate: self, delegateQueue: dispatch_get_main_queue())
25 | serverSocket = GCDAsyncSocket(delegate: self, delegateQueue: dispatch_get_main_queue())
26 | }
27 |
28 | override func tearDown() {
29 | // Put teardown code here. This method is called after the invocation of each test method in the class.
30 | super.tearDown()
31 | clientSocket?.disconnect()
32 | serverSocket?.disconnect()
33 | acceptedServerSocket?.disconnect()
34 | clientSocket = nil
35 | serverSocket = nil
36 | acceptedServerSocket = nil
37 | }
38 |
39 | func testFullConnection() {
40 | // This is an example of a functional test case.
41 | // Use XCTAssert and related functions to verify your tests produce the correct results.
42 | do {
43 | try serverSocket?.acceptOnPort(kTestPort)
44 | } catch {
45 | XCTFail("\(error)")
46 | }
47 | do {
48 | try clientSocket?.connectToHost("127.0.0.1", onPort: kTestPort)
49 | } catch {
50 | XCTFail("\(error)")
51 | }
52 | expectation = expectationWithDescription("Test Full connnection")
53 | waitForExpectationsWithTimeout(30) { (error: NSError?) -> Void in
54 | if error != nil {
55 | XCTFail("\(error)")
56 | }
57 | }
58 | }
59 |
60 |
61 | //MARK:- GCDAsyncSocketDelegate
62 | func socket(sock: GCDAsyncSocket!, didAcceptNewSocket newSocket: GCDAsyncSocket!) {
63 | NSLog("didAcceptNewSocket %@ %@", sock, newSocket)
64 | acceptedServerSocket = newSocket
65 | }
66 |
67 | func socket(sock: GCDAsyncSocket!, didConnectToHost host: String!, port: UInt16) {
68 | NSLog("didConnectToHost %@ %@ %d", sock, host, port);
69 | expectation?.fulfill()
70 | }
71 |
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/Tests/iOS/CocoaAsyncSocket.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Tests/iOS/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/CocoaAsyncSocketTestsiOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/Tests/iOS/CocoaAsyncSocket.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Tests/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.chrisballinger.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Tests/iOS/Podfile:
--------------------------------------------------------------------------------
1 | source 'https://github.com/CocoaPods/Specs.git'
2 |
3 | use_frameworks!
4 |
5 | target :CocoaAsyncSocketTestsiOS do
6 | platform :ios, '8.0'
7 | pod 'CocoaAsyncSocket', :path => '../../CocoaAsyncSocket.podspec'
8 | end
--------------------------------------------------------------------------------
/Tests/iOS/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - CocoaAsyncSocket (7.4.2):
3 | - CocoaAsyncSocket/All (= 7.4.2)
4 | - CocoaAsyncSocket/All (7.4.2):
5 | - CocoaAsyncSocket/GCD
6 | - CocoaAsyncSocket/RunLoop
7 | - CocoaAsyncSocket/GCD (7.4.2)
8 | - CocoaAsyncSocket/RunLoop (7.4.2)
9 |
10 | DEPENDENCIES:
11 | - CocoaAsyncSocket (from `../../CocoaAsyncSocket.podspec`)
12 |
13 | EXTERNAL SOURCES:
14 | CocoaAsyncSocket:
15 | :path: "../../CocoaAsyncSocket.podspec"
16 |
17 | SPEC CHECKSUMS:
18 | CocoaAsyncSocket: ea27dc2477a5e83223ca93531ad4508180744c35
19 |
20 | COCOAPODS: 0.39.0
21 |
--------------------------------------------------------------------------------