Permalink
Browse files

Add separate methods for sending strings and binary data.

  • Loading branch information...
1 parent 6d1f992 commit 8d79e45647d32a873492335ee60c63e7f01f75e8 @pk committed May 22, 2012
Showing with 19 additions and 2 deletions.
  1. +1 −0 PKWebSocket/Handlers/PKWebSocketHandler.m
  2. +3 −0 PKWebSocket/PKWebSocket.h
  3. +15 −2 PKWebSocket/PKWebSocket.m
@@ -250,6 +250,7 @@ - (void)onSocketDidSecure:(AsyncSocket *)sock {
self->_didSecure = YES;
}
+
#pragma mark - Frame delegate
- (void)parserNeedsReadDataToData:(NSData *)boundary {
@@ -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
@@ -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
}
}

0 comments on commit 8d79e45

Please sign in to comment.