Skip to content

Commit

Permalink
another adjustment for timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
TorutheRedFox committed Oct 19, 2023
1 parent 76a21da commit 3839bf9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Discord Classic/DCChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (void)sendMessage:(NSString*)message {
dispatch_async(apiQueue, ^{
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/channels/%@/messages", self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:40];

NSString* escapedMessage = [message mutableCopy];

Expand Down Expand Up @@ -73,7 +73,7 @@ - (void)sendImage:(UIImage*)image {
dispatch_async(apiQueue, ^{
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/channels/%@/messages", self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:40];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];

[urlRequest setHTTPMethod:@"POST"];

Expand Down Expand Up @@ -112,7 +112,7 @@ - (void)sendTypingIndicator{
dispatch_async(apiQueue, ^{
NSURL* channelURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://discordapp.com/api/channels/%@/typing", self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:2];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5]; // low timeout to avoid API spam

[urlRequest setHTTPMethod:@"POST"];

Expand All @@ -137,7 +137,7 @@ - (void)ackMessage:(NSString*)messageId{
dispatch_async(apiQueue, ^{
NSURL* channelURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://discordapp.com/api/channels/%@/messages/%@/ack", self.snowflake, messageId]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];

[urlRequest setHTTPMethod:@"POST"];

Expand Down Expand Up @@ -171,7 +171,7 @@ - (NSArray*)getMessages:(int)numberOfMessages beforeMessage:(DCMessage*)message{
if(message)
[getChannelAddress appendString:[NSString stringWithFormat:@"before=%@", message.snowflake]];

NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:getChannelAddress] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:getChannelAddress] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:40];

[urlRequest addValue:DCServerCommunicator.sharedInstance.token forHTTPHeaderField:@"Authorization"];
[urlRequest addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
Expand Down
2 changes: 1 addition & 1 deletion Discord Classic/DCMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ - (void)deleteMessage{
dispatch_async(apiQueue, ^{
NSURL* messageURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/v6/channels/%@/messages/%@", DCServerCommunicator.sharedInstance.selectedChannel.snowflake, self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:messageURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:messageURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:40];

[urlRequest setHTTPMethod:@"DELETE"];

Expand Down
2 changes: 1 addition & 1 deletion Discord Classic/DCTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ + (void)joinGuild:(NSString*)inviteCode {
//dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
NSURL* guildURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/v6/invite/%@", inviteCode]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:guildURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:guildURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:40];

[urlRequest setHTTPMethod:@"POST"];

Expand Down

0 comments on commit 3839bf9

Please sign in to comment.