Created
September 8, 2014 22:17
-
-
Save foozmeat/d0a1fe8f7beceef139b0 to your computer and use it in GitHub Desktop.
Revisions
-
foozmeat created this gist
Sep 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ // // PANWebServerConnection.h // // Created by James Moore on 9/8/14. // #import "GCDWebServerConnection.h" @interface PANWebServerConnection : GCDWebServerConnection @end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ // // PANWebServerConnection.m // // Created by James Moore on 9/8/14. // #import "PANWebServerConnection.h" @interface PANWebServerConnection() @end const NSUInteger throughput = 14400; const NSUInteger minimumDelay = 1000000; @implementation PANWebServerConnection - (void)didReadBytes:(const void *)bytes length:(NSUInteger)length { [self delayForLength:length]; [super didReadBytes:bytes length:length]; } - (void)didWriteBytes:(const void *)bytes length:(NSUInteger)length { [self delayForLength:length]; [super didReadBytes:bytes length:length]; } - (void)delayForLength:(NSUInteger)length { NSUInteger delay = ((length / throughput) * 1000000); if (delay < minimumDelay) { delay = minimumDelay; } usleep((unsigned int)delay); } @end