Skip to content

Instantly share code, notes, and snippets.

@idyll
Created July 7, 2012 09:52
Show Gist options
  • Save idyll/3065685 to your computer and use it in GitHub Desktop.
Save idyll/3065685 to your computer and use it in GitHub Desktop.
Objective-C Client for @tenderlove's housefire
//
// main.m
//
// Created by Mark Madsen on 2012-07-07.
// Copyright (c) 2012 AGiLE ANiMAL INC. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AFHTTPClient.h"
#import "AFHTTPRequestOperation.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSURL * url = [NSURL URLWithString:@"http://joy.anml.io:9292/chat.json"];
NSLog(@"port:%@", [url.port description]);
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:100000.0];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.outputStream = [NSOutputStream outputStreamToMemory];
[operation setDownloadProgressBlock:^(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
NSData * data = [operation.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
NSLog(@"DATA %@", [[NSString alloc] initWithData:data encoding:NSStringEncodingConversionAllowLossy]);
}];
[operation start];
while(1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment