195 [self.stream write:(const uint8_t *)buffer maxLength:length]; |
195 [self.stream write:(const uint8_t *)buffer maxLength:length]; |
196 } |
196 } |
197 |
197 |
198 // wrapper that computes the length of the message and then sends the command string, saving the command on a file |
198 // wrapper that computes the length of the message and then sends the command string, saving the command on a file |
199 -(int) sendToEngine:(NSString *)string { |
199 -(int) sendToEngine:(NSString *)string { |
200 uint8_t length = [string length]; |
200 uint8_t length = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; |
201 |
201 |
202 [self dumpRawData:[string UTF8String] ofSize:length]; |
202 [self dumpRawData:[string UTF8String] ofSize:length]; |
203 SDLNet_TCP_Send(csd, &length, 1); |
203 SDLNet_TCP_Send(csd, &length, 1); |
204 return SDLNet_TCP_Send(csd, [string UTF8String], length); |
204 return SDLNet_TCP_Send(csd, [string UTF8String], length); |
205 } |
205 } |
206 |
206 |
207 // wrapper that computes the length of the message and then sends the command string, skipping file writing |
207 // wrapper that computes the length of the message and then sends the command string, skipping file writing |
208 -(int) sendToEngineNoSave:(NSString *)string { |
208 -(int) sendToEngineNoSave:(NSString *)string { |
209 uint8_t length = [string length]; |
209 uint8_t length = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; |
210 |
210 |
211 SDLNet_TCP_Send(csd, &length, 1); |
211 SDLNet_TCP_Send(csd, &length, 1); |
212 return SDLNet_TCP_Send(csd, [string UTF8String], length); |
212 return SDLNet_TCP_Send(csd, [string UTF8String], length); |
213 } |
213 } |
214 |
214 |