Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add separate methods for sending strings and binary data.

  • Loading branch information...
commit 8d79e45647d32a873492335ee60c63e7f01f75e8 1 parent 6d1f992
@pk authored
View
1  PKWebSocket/Handlers/PKWebSocketHandler.m
@@ -250,6 +250,7 @@ - (void)onSocketDidSecure:(AsyncSocket *)sock {
self->_didSecure = YES;
}
+
#pragma mark - Frame delegate
- (void)parserNeedsReadDataToData:(NSData *)boundary {
View
3  PKWebSocket/PKWebSocket.h
@@ -39,7 +39,10 @@
- (void)close;
- (BOOL)openWithURLString:(NSString *)url error:(NSError **)error;
+
- (void)send:(PKWebSocketMessage *)message;
+- (void)sendString:(NSString *)aString;
+- (void)sendData:(NSData *)aData;
- (void)setTLSSettings:(NSDictionary *)settings;
- (NSDictionary *)TLSSettings;
View
17 PKWebSocket/PKWebSocket.m
@@ -66,12 +66,22 @@ - (void)send:(PKWebSocketMessage *)aMessage {
NSParameterAssert(aMessage);
if ([aMessage isBinary]) {
- [self.handler sendBinaryFrameWithData:aMessage.data];
+ [self sendData:aMessage.data];
} else {
- [self.handler sendTextFrameWithString:aMessage.string];
+ [self sendString:aMessage.string];
}
}
+- (void)sendString:(NSString *)aString {
+ NSParameterAssert(aString);
+ [self.handler sendTextFrameWithString:aString];
+}
+
+- (void)sendData:(NSData *)aData {
+ NSParameterAssert(aData);
+ [self.handler sendBinaryFrameWithData:aData];
+}
+
#pragma mark - Accessors
@@ -113,7 +123,10 @@ - (void)handler:(PKWebSocketHandler *)handler didChangeStatus:(PKWebSocketStatus
break;
}
if (sel != NULL && [_delegate respondsToSelector:sel]) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[_delegate performSelector:sel withObject:self];
+#pragma clang diagnostic pop
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.