equal
deleted
inserted
replaced
61 |
61 |
62 #pragma mark - |
62 #pragma mark - |
63 #pragma mark Spawner functions |
63 #pragma mark Spawner functions |
64 -(void) spawnThread:(NSString *)onSaveFile withOptions:(NSDictionary *)dictionary { |
64 -(void) spawnThread:(NSString *)onSaveFile withOptions:(NSDictionary *)dictionary { |
65 self.stream = [[NSOutputStream alloc] initToFileAtPath:onSaveFile append:YES]; |
65 self.stream = [[NSOutputStream alloc] initToFileAtPath:onSaveFile append:YES]; |
66 |
66 [self.stream open]; |
67 [NSThread detachNewThreadSelector:@selector(engineProtocol) |
67 |
|
68 [NSThread detachNewThreadSelector:@selector(engineProtocol:) |
68 toTarget:self |
69 toTarget:self |
69 withObject:dictionary]; |
70 withObject:dictionary]; |
70 } |
71 } |
71 |
72 |
72 -(void) spawnThread:(NSString *)onSaveFile { |
73 -(void) spawnThread:(NSString *)onSaveFile { |
208 } |
209 } |
209 |
210 |
210 #pragma mark - |
211 #pragma mark - |
211 #pragma mark Network relevant code |
212 #pragma mark Network relevant code |
212 -(void) dumpRawData:(const char *)buffer ofSize:(uint8_t) length { |
213 -(void) dumpRawData:(const char *)buffer ofSize:(uint8_t) length { |
213 [self.stream open]; |
|
214 [self.stream write:&length maxLength:1]; |
214 [self.stream write:&length maxLength:1]; |
215 [self.stream write:(const uint8_t *)buffer maxLength:length]; |
215 [self.stream write:(const uint8_t *)buffer maxLength:length]; |
216 [self.stream close]; |
|
217 } |
216 } |
218 |
217 |
219 // wrapper that computes the length of the message and then sends the command string, saving the command on a file |
218 // wrapper that computes the length of the message and then sends the command string, saving the command on a file |
220 -(int) sendToEngine:(NSString *)string { |
219 -(int) sendToEngine:(NSString *)string { |
221 uint8_t length = [string length]; |
220 uint8_t length = [string length]; |
405 [self dumpRawData:buffer ofSize:msgSize]; |
404 [self dumpRawData:buffer ofSize:msgSize]; |
406 break; |
405 break; |
407 } |
406 } |
408 } |
407 } |
409 DLog(@"Engine exited, ending thread"); |
408 DLog(@"Engine exited, ending thread"); |
|
409 [self.stream close]; |
410 |
410 |
411 // Close the client socket |
411 // Close the client socket |
412 SDLNet_TCP_Close(csd); |
412 SDLNet_TCP_Close(csd); |
413 SDLNet_Quit(); |
413 SDLNet_Quit(); |
414 |
414 |