diff --git a/README.md b/README.md index 94697582..acc182d1 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ You implement this - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessageWithData:(NSData *)data; - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error; -- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(nullable NSString *)reason wasClean:(BOOL)wasClean; +- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(SRStatusCode)code reason:(nullable NSString *)reason wasClean:(BOOL)wasClean; @end ``` diff --git a/SocketRocket/SRWebSocket.h b/SocketRocket/SRWebSocket.h index f7d96cd3..267f7843 100644 --- a/SocketRocket/SRWebSocket.h +++ b/SocketRocket/SRWebSocket.h @@ -256,7 +256,7 @@ extern NSString *const SRHTTPResponseErrorKey; @param code Code to close the socket with. @param reason Reason to send to the server or `nil`. */ -- (void)closeWithCode:(NSInteger)code reason:(nullable NSString *)reason; +- (void)closeWithCode:(SRStatusCode)code reason:(nullable NSString *)reason; ///-------------------------------------- #pragma mark Send @@ -385,7 +385,7 @@ extern NSString *const SRHTTPResponseErrorKey; @param reason Reason in a form of a String that was reported by the server or `nil`. @param wasClean Boolean value indicating whether a socket was closed in a clean state. */ -- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(nullable NSString *)reason wasClean:(BOOL)wasClean; +- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(SRStatusCode)code reason:(nullable NSString *)reason wasClean:(BOOL)wasClean; /** Called on receive of a ping message from the server. diff --git a/SocketRocket/SRWebSocket.m b/SocketRocket/SRWebSocket.m index 02a57de1..243d3778 100644 --- a/SocketRocket/SRWebSocket.m +++ b/SocketRocket/SRWebSocket.m @@ -124,7 +124,7 @@ @implementation SRWebSocket { BOOL _sentClose; BOOL _didFail; BOOL _cleanupScheduled; - int _closeCode; + SRStatusCode _closeCode; BOOL _isPumping; @@ -512,7 +512,7 @@ - (void)close [self closeWithCode:SRStatusCodeNormal reason:nil]; } -- (void)closeWithCode:(NSInteger)code reason:(NSString *)reason +- (void)closeWithCode:(SRStatusCode)code reason:(NSString *)reason { assert(code); __weak typeof(self) wself = self; @@ -778,7 +778,7 @@ - (void)handleCloseWithData:(NSData *)data [self assertOnWorkQueue]; if (self.readyState == SR_OPEN) { - [self closeWithCode:1000 reason:nil]; + [self closeWithCode:SRStatusCodeNormal reason:nil]; } dispatch_async(_workQueue, ^{ [self closeConnection];