Skip to content

Instantly share code, notes, and snippets.

@kevinpiac
Created September 2, 2017 13:22
Show Gist options
  • Save kevinpiac/05dbfa6f185af898b5b465fa33710d1a to your computer and use it in GitHub Desktop.
Save kevinpiac/05dbfa6f185af898b5b465fa33710d1a to your computer and use it in GitHub Desktop.
- (void)onMessageAction:(NSString *)message
{
@autoreleasepool {
NSArray *request = [message componentsSeparatedByString:@":"];
if (request.count >= 3)
{
NSString *clientId = request[1];
NSString *action = request[2];
NSString *response;
[logTool logDataFromNSString:[NSString stringWithFormat:@"request: %@", request]];
if ([action isEqualToString:@"add_friend"])
response = [tweakRequest createFriendAdditionRequestWithAuthToken: request[3] username: request[4]];
else if ([action isEqualToString:@"friends"])
response = [tweakRequest createFriendsRequestWithAuthToken: request[3] username: request[4]];
else if ([action isEqualToString:@"upload"])
response = [tweakRequest createUploadRequestWithAuthToken: request[3] username: request[4] mediaId: request[5] mediaType: request[6]];
else if ([action isEqualToString:@"post_story"])
response = [tweakRequest createPostStoryRequestWithAuthToken: request[3] username: request[4] mediaId: request[5] mediaType: request[6] storyTimestamp: request[7]];
// TRUNCATED
[self sendMessage:[NSString stringWithFormat:@"2:response:%@:%@", clientId, response]];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment