Skip to content

Commit

Permalink
Scheduling improvements
Browse files Browse the repository at this point in the history
By default now, SRWebSocket will schedule the network on a shared
background thread

It can also be configured to call the delegate methods on a non-main
queue
  • Loading branch information
mikelikespie committed Sep 16, 2012
1 parent 16d7205 commit 75fd01c
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 48 deletions.
6 changes: 5 additions & 1 deletion SocketRocket.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
27FF2C2916066747006EF077 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 27FF2C2816066746006EF077 /* Default-568h@2x.png */; };
F6016C7C146124B20037BB3D /* base64.c in Sources */ = {isa = PBXBuildFile; fileRef = F6016C7B146124B20037BB3D /* base64.c */; };
F6016C7F146124ED0037BB3D /* base64.h in Headers */ = {isa = PBXBuildFile; fileRef = F6016C7E146124ED0037BB3D /* base64.h */; };
F6016C8814620EC70037BB3D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6A12CD3145122FC00C1D980 /* Security.framework */; };
Expand Down Expand Up @@ -59,6 +60,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
27FF2C2816066746006EF077 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = "<group>"; };
F6016C7B146124B20037BB3D /* base64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = base64.c; sourceTree = "<group>"; };
F6016C7E146124ED0037BB3D /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base64.h; sourceTree = "<group>"; };
F60CC29F14D4EA0500A005E4 /* SRTWebSocketOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRTWebSocketOperation.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -175,6 +177,7 @@
F62417EB14D52F3C003CE997 /* Supporting Files */ = {
isa = PBXGroup;
children = (
27FF2C2816066746006EF077 /* Default-568h@2x.png */,
F62417EC14D52F3C003CE997 /* TestChat-Info.plist */,
F62417ED14D52F3C003CE997 /* InfoPlist.strings */,
F62417F014D52F3C003CE997 /* main.m */,
Expand Down Expand Up @@ -397,7 +400,7 @@
F6B208241450F597009315AF /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
LastUpgradeCheck = 0450;
};
buildConfigurationList = F6B208271450F597009315AF /* Build configuration list for PBXProject "SocketRocket" */;
compatibilityVersion = "Xcode 3.2";
Expand Down Expand Up @@ -426,6 +429,7 @@
files = (
F62417EF14D52F3C003CE997 /* InfoPlist.strings in Resources */,
F62417F814D52F3C003CE997 /* MainStoryboard.storyboard in Resources */,
27FF2C2916066747006EF077 /* Default-568h@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
13 changes: 13 additions & 0 deletions SocketRocket/SRWebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ extern NSString *const SRWebSocketErrorDomain;
- (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols;
- (id)initWithURL:(NSURL *)url;

// Delegage queue will be +[NSOperationQueue mainQueue] by default
- (void)setDelegateQueue:(NSOperationQueue*) queue;

// By default, it will schedule itself on +[NSRunLoop SR_networkRunLoop] using defaultModes
- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode;
- (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode;

// SRWebSockets are intended one-time-use only. Open should be called once and only once
- (void)open;

Expand Down Expand Up @@ -88,3 +95,9 @@ extern NSString *const SRWebSocketErrorDomain;
@property (nonatomic, retain) NSArray *SR_SSLPinnedCertificates;

@end

@interface NSRunLoop (SRWebSocket)

+ (NSRunLoop *)SR_networkRunLoop;

@end
Loading

0 comments on commit 75fd01c

Please sign in to comment.