Permalink
Browse files

Remove forgotten testing stuff; Fix getting any data from server

  • Loading branch information...
1 parent d1ef719 commit 12ffd38737bd472e0d43ffc5ec9b0b95a9197662 @kylehickinson committed Nov 3, 2012
Showing with 5 additions and 24 deletions.
  1. +0 −23 iOS/Reflect/RFClient.m
  2. +5 −1 iOS/Reflect/RFRootViewController.m
View
@@ -186,25 +186,6 @@ - (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDic
NSLog(@"Failed to resolve: %@", errorDict);
}
-- (NSString *)_logPacketData:(uint8_t *)data size:(uint64_t)size detailed:(BOOL)detailed
-{
- if (size == 0) return nil;
-
- NSMutableString *packetString = [NSMutableString string];
- for (int i = 0, x = 0; i < size; i++) {
- [packetString appendFormat:@"%02X ", data[i]];
-
- if (!detailed && (i > 16 && x == 0)) {
- [packetString appendString:@"... "];
- i = (size-16);
- x = 1;
- }
- }
-
- NSArray *headers = @[ @"RFServerSendingDataInformation", @"RFServerSendingData", @"RFServerRequiresPasscode", @"RFServerReceivedInvalidPasscode" ];
- return [NSString stringWithFormat:@"read (%@ : %lld bytes): %@", ((data[0]-RFServerSendingDataInformation) >= [headers count] ? nil : headers[data[0]-RFServerSendingDataInformation]), size, packetString];
-}
-
- (void)_appendBytesAndCheck:(uint8_t *)bytes length:(NSInteger)length
{
if (length == 0) return;
@@ -228,7 +209,6 @@ - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
static NSMutableArray *packetLog = nil;
if (self.data == nil) {
- packetLog = [[NSMutableArray alloc] init];
self.data = [[NSMutableData alloc] init];
}
@@ -241,8 +221,6 @@ - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
uint8_t buf[1024];
len = [self.inputStream read:buf maxLength:1024];
if (len > 0) {
- [packetLog addObject:[self _logPacketData:buf size:len detailed:NO]];
-
if (self.readingData) {
// Anything after the target data size is sent _should_ be image data.
// Also gotta make sure we got our first batch of data (with the begin header...)
@@ -311,7 +289,6 @@ - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
}
case NSStreamEventEndEncountered: {
- [packetLog removeAllObjects];
[self stopStreaming];
[self.delegate clientDidDisconnectFromService:self];
@@ -157,6 +157,10 @@ - (void)client:(RFClient *)client willReceiveDataWithLength:(uint64_t)length
- (void)client:(RFClient *)client didRecieveData:(NSData *)data
{
+ // Make sure we only take image data.
+ UIImage *image = [UIImage imageWithData:data];
+ if (image == nil) return;
+
if (!self.imageView) {
self.imageView = [[RFImageViewController alloc] initWithFrame:self.view.bounds];
self.imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
@@ -169,7 +173,7 @@ - (void)client:(RFClient *)client didRecieveData:(NSData *)data
}
self.imageView.showImageUpdateActivityIndicator = NO;
- self.imageView.image = [UIImage imageWithData:data];
+ self.imageView.image = image;
}
- (void)client:(RFClient *)client didUpdateServicesList:(NSArray *)services

0 comments on commit 12ffd38

Please sign in to comment.