-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGCDAsyncSocket-writeData.xm
31 lines (20 loc) · 1.06 KB
/
GCDAsyncSocket-writeData.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%hook GCDAsyncSocket
- (void)writeData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag {
NSString* xml = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSUInteger length = [xml length];
int divide_factor = 900;
NSString *isFirst = @"-start";
if(length > divide_factor) {
NSMutableString *mutatingXmlStr = [xml mutableCopy];
while (mutatingXmlStr.length) {
NSString* substring = [mutatingXmlStr substringWithRange:NSMakeRange(0, MIN(divide_factor, mutatingXmlStr.length))];
mutatingXmlStr = [[mutatingXmlStr stringByReplacingCharactersInRange:NSMakeRange(0, MIN(divide_factor, mutatingXmlStr.length)) withString:@""] mutableCopy];
NSLog(@"XMPPFramework send-partial%@: %@\n", isFirst, substring);
isFirst = @"-contd";
}
} else {
NSLog(@"XMPPFramework send: %@", xml);
}
%orig;
}
%end