git.ithinksw.org
/
MenuTunes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More networking improvements.
[MenuTunes.git]
/
MainController.m
diff --git
a/MainController.m
b/MainController.m
index
8abe8de
..
ecf39ba
100755
(executable)
--- a/
MainController.m
+++ b/
MainController.m
@@
-89,7
+89,7
@@
static MainController *sharedController;
if ([df boolForKey:@"enableSharing"]) {
[self setServerStatus:YES];
} else if ([df boolForKey:@"useSharedPlayer"]) {
if ([df boolForKey:@"enableSharing"]) {
[self setServerStatus:YES];
} else if ([df boolForKey:@"useSharedPlayer"]) {
- [self checkForRemoteServer];
+ [self checkForRemoteServer
AndConnectImmediately:YES
];
}
//Setup for notification of the remote player launching or quitting
}
//Setup for notification of the remote player launching or quitting
@@
-1131,9
+1131,14
@@
static MainController *sharedController;
}
- (void)checkForRemoteServer
}
- (void)checkForRemoteServer
+{
+ [self checkForRemoteServerAndConnectImmediately:NO];
+}
+
+- (void)checkForRemoteServerAndConnectImmediately:(BOOL)connectImmediately
{
ITDebugLog(@"Checking for remote server.");
{
ITDebugLog(@"Checking for remote server.");
- [NSThread detachNewThreadSelector:@selector(runRemoteServerCheck:) toTarget:self withObject:
nil
];
+ [NSThread detachNewThreadSelector:@selector(runRemoteServerCheck:) toTarget:self withObject:
[NSNumber numberWithBool:connectImmediately]
];
}
- (void)runRemoteServerCheck:(id)sender
}
- (void)runRemoteServerCheck:(id)sender
@@
-1142,7
+1147,11
@@
static MainController *sharedController;
ITDebugLog(@"Remote server check running.");
if ([networkController checkForServerAtHost:[df stringForKey:@"sharedPlayerHost"]]) {
ITDebugLog(@"Remote server found.");
ITDebugLog(@"Remote server check running.");
if ([networkController checkForServerAtHost:[df stringForKey:@"sharedPlayerHost"]]) {
ITDebugLog(@"Remote server found.");
- [self performSelectorOnMainThread:@selector(remoteServerFound:) withObject:nil waitUntilDone:NO];
+ if ([sender boolValue]) {
+ [self performSelectorOnMainThread:@selector(connectToServer) withObject:nil waitUntilDone:NO];
+ } else {
+ [self performSelectorOnMainThread:@selector(remoteServerFound:) withObject:nil waitUntilDone:NO];
+ }
} else {
ITDebugLog(@"Remote server not found.");
[self performSelectorOnMainThread:@selector(remoteServerNotFound:) withObject:nil waitUntilDone:NO];
} else {
ITDebugLog(@"Remote server not found.");
[self performSelectorOnMainThread:@selector(remoteServerNotFound:) withObject:nil waitUntilDone:NO];
@@
-1159,7
+1168,9
@@
static MainController *sharedController;
- (void)remoteServerNotFound:(id)sender
{
- (void)remoteServerNotFound:(id)sender
{
- [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
+ if (![[NetworkController sharedController] isConnectedToServer]) {
+ [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
+ }
}
- (void)networkError:(NSException *)exception
}
- (void)networkError:(NSException *)exception
@@
-1170,7
+1181,7
@@
static MainController *sharedController;
[[StatusWindowController sharedController] showNetworkErrorQueryWindow];
if ([self disconnectFromServer]) {
[[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
[[StatusWindowController sharedController] showNetworkErrorQueryWindow];
if ([self disconnectFromServer]) {
[[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
- [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:
YES
];
+ [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:
NO
];
} else {
ITDebugLog(@"CRITICAL ERROR, DISCONNECTING!");
}
} else {
ITDebugLog(@"CRITICAL ERROR, DISCONNECTING!");
}
@@
-1179,9
+1190,10
@@
static MainController *sharedController;
- (void)reconnect
{
- (void)reconnect
{
- if ([self connectToServer] == 0) {
- [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:YES];
- }
+ /*if ([self connectToServer] == 0) {
+ [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
+ }*/
+ [self checkForRemoteServerAndConnectImmediately:YES];
[[StatusWindow sharedWindow] setLocked:NO];
[[StatusWindow sharedWindow] vanish:self];
[[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
[[StatusWindow sharedWindow] setLocked:NO];
[[StatusWindow sharedWindow] vanish:self];
[[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];