Selaa lähdekoodia

Merge pull request #61 from charlesmchen/master

Comment cleanup.
Mike Lewis 12 vuotta sitten
vanhempi
commit
97f48e4474
2 muutettua tiedostoa jossa 28 lisäystä ja 19 poistoa
  1. 20 11
      SocketRocket/SRWebSocket.h
  2. 8 8
      SocketRocket/SRWebSocket.m

+ 20 - 11
SocketRocket/SRWebSocket.h

@@ -22,15 +22,18 @@ typedef enum {
     SR_OPEN         = 1,
     SR_CLOSING      = 2,
     SR_CLOSED       = 3,
-    
 } SRReadyState;
 
 @class SRWebSocket;
 
 extern NSString *const SRWebSocketErrorDomain;
 
+#pragma mark - SRWebSocketDelegate
+
 @protocol SRWebSocketDelegate;
 
+#pragma mark - SRWebSocket
+
 @interface SRWebSocket : NSObject <NSStreamDelegate>
 
 @property (nonatomic, assign) id <SRWebSocketDelegate> delegate;
@@ -39,41 +42,43 @@ extern NSString *const SRWebSocketErrorDomain;
 @property (nonatomic, readonly, retain) NSURL *url;
 
 // This returns the negotiated protocol.
-// It will be niluntil after the handshake completes.
+// It will be nil until after the handshake completes.
 @property (nonatomic, readonly, copy) NSString *protocol;
 
-// Protocols should be an array of strings that turn into Sec-WebSocket-Protocol
+// Protocols should be an array of strings that turn into Sec-WebSocket-Protocol.
 - (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols;
 - (id)initWithURLRequest:(NSURLRequest *)request;
 
-// Some helper constructors
+// Some helper constructors.
 - (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols;
 - (id)initWithURL:(NSURL *)url;
 
-// Delegage queue will be dispatch_main_queue by default
-// Only can set OperationQeuue or dispatch_queue
+// Delegate queue will be dispatch_main_queue by default.
+// You cannot set both OperationQueue and dispatch_queue.
 - (void)setDelegateOperationQueue:(NSOperationQueue*) queue;
 - (void)setDelegateDispatchQueue:(dispatch_queue_t) queue;
 
-// By default, it will schedule itself on +[NSRunLoop SR_networkRunLoop] using defaultModes
+// 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
+// SRWebSockets are intended for one-time-use only.  Open should be called once and only once.
 - (void)open;
 
 - (void)close;
 - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason;
 
-// Send a UTF8 String or Data
+// Send a UTF8 String or Data.
 - (void)send:(id)data;
 
 @end
 
+#pragma mark - SRWebSocketDelegate
+
 @protocol SRWebSocketDelegate <NSObject>
 
-// message will either be an NSString if the server is using text 
-// or NSData if the server is using binary
+// message will either be an NSString if the server is using text
+// or NSData if the server is using binary.
 - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message;
 
 @optional
@@ -84,6 +89,7 @@ extern NSString *const SRWebSocketErrorDomain;
 
 @end
 
+#pragma mark - NSURLRequest (CertificateAdditions)
 
 @interface NSURLRequest (CertificateAdditions)
 
@@ -91,6 +97,7 @@ extern NSString *const SRWebSocketErrorDomain;
 
 @end
 
+#pragma mark - NSMutableURLRequest (CertificateAdditions)
 
 @interface NSMutableURLRequest (CertificateAdditions)
 
@@ -98,6 +105,8 @@ extern NSString *const SRWebSocketErrorDomain;
 
 @end
 
+#pragma mark - NSRunLoop (SRWebSocket)
+
 @interface NSRunLoop (SRWebSocket)
 
 + (NSRunLoop *)SR_networkRunLoop;

+ 8 - 8
SocketRocket/SRWebSocket.m

@@ -40,11 +40,11 @@
 typedef enum  {
     SROpCodeTextFrame = 0x1,
     SROpCodeBinaryFrame = 0x2,
-    //3-7Reserved 
+    // 3-7 reserved.
     SROpCodeConnectionClose = 0x8,
     SROpCodePing = 0x9,
     SROpCodePong = 0xA,
-    //B-F reserved
+    // B-F reserved.
 } SROpCode;
 
 typedef enum {
@@ -52,9 +52,9 @@ typedef enum {
     SRStatusCodeGoingAway = 1001,
     SRStatusCodeProtocolError = 1002,
     SRStatusCodeUnhandledType = 1003,
-    // 1004 reserved
+    // 1004 reserved.
     SRStatusNoStatusReceived = 1005,
-    // 1004-1006 reserved
+    // 1004-1006 reserved.
     SRStatusCodeInvalidUTF8 = 1007,
     SRStatusCodePolicyViolated = 1008,
     SRStatusCodeMessageTooBig = 1009,
@@ -92,8 +92,8 @@ static inline void SRFastLog(NSString *format, ...);
 
 @interface NSURL (SRWebSocket)
 
-// The origin isn't really applicable for a native application
-// So instead, just map ws -> http and wss -> https
+// The origin isn't really applicable for a native application.
+// So instead, just map ws -> http and wss -> https.
 - (NSString *)SR_origin;
 
 @end
@@ -145,7 +145,7 @@ static NSString *newSHA1String(const char *bytes, size_t length) {
 
 NSString *const SRWebSocketErrorDomain = @"SRWebSocketErrorDomain";
 
-// Returns number of bytes consumed. returning 0 means you didn't match.
+// Returns number of bytes consumed. Returning 0 means you didn't match.
 // Sends bytes to callback handler;
 typedef size_t (^stream_scanner)(NSData *collected_data);
 
@@ -166,7 +166,7 @@ typedef void (^data_callback)(SRWebSocket *webSocket,  NSData *data);
 
 @end
 
-// This class is not thread-safe, and is expected to always be run on the same queue
+// This class is not thread-safe, and is expected to always be run on the same queue.
 @interface SRIOConsumerPool : NSObject
 
 - (id)initWithBufferCapacity:(NSUInteger)poolSize;