Permalink
Browse files

Reworked how the touch handler handles net service resolution so that…

… it's more robust

Fixed a problem where a net service was getting resolved a second time (turns out that's a valid thing to happen and I would have know it if I'd bothered to RTFM) and was causing a second set of sync messages to be sent to the server, confusing and breaking the sync
  • Loading branch information...
Michael Fey Michael Fey
Michael Fey authored and Michael Fey committed Sep 24, 2010
1 parent edade0f commit dd27b152bf1a79cd1f27a02b59a161c588151c68
Showing with 489 additions and 313 deletions.
  1. +0 −20 DesktopCode/ZSyncConnectionDelegate.m
  2. +14 −4 DeviceCode/ZSyncTouchHandler.h
  3. +475 −289 DeviceCode/ZSyncTouchHandler.m
@@ -485,7 +485,6 @@ - (BOOL)connection:(BLIPConnection *)con receivedRequest:(BLIPRequest *)request
DLog(@"%s entered", __PRETTY_FUNCTION__);
NSInteger action = [[[request properties] valueOfProperty:zsAction] integerValue];
- BLIPResponse *response = [request response];
switch (action) {
case zsActionLatentDeregisterClient:
DLog(@"%s zsActionLatentDeregisterClient", __PRETTY_FUNCTION__);
@@ -509,25 +508,6 @@ - (BOOL)connection:(BLIPConnection *)con receivedRequest:(BLIPRequest *)request
[self showCodeWindow];
return YES;
-// case zsActionAuthenticatePairing:
-// DLog(@"%s zsActionAuthenticatePairing", __PRETTY_FUNCTION__);
-// ALog(@"Is this ever called?");
-// if ([[self pairingCode] isEqualToString:[request bodyString]]) {
-// DLog(@"%s passed '%@' '%@'", __PRETTY_FUNCTION__, [request bodyString], [self pairingCode]);
-// // TODO: Register the unique ID of this service
-// [response setValue:zsActID(zsActionAuthenticatePassed) ofProperty:zsAction];
-// [response setValue:[[NSUserDefaults standardUserDefaults] valueForKey:zsServerUUID] ofProperty:zsServerUUID];
-// [response setValue:[[ZSyncHandler shared] serverName] ofProperty:zsServerName];
-// [response send];
-// [[self pairingCodeWindowController] close];
-// [self setPairingCodeWindowController:nil];
-// } else {
-// DLog(@"%s failed '%@' '%@'", __PRETTY_FUNCTION__, [request bodyString], [self pairingCode]);
-// [response setValue:zsActID(zsActionAuthenticateFailed) ofProperty:zsAction];
-// [response send];
-// }
-// return YES;
-
case zsActionVerifyPairing:
// TODO: This method should verify that the client is paired properly, responding accordingly
return YES;
@@ -133,8 +133,13 @@ typedef enum {
NSMutableArray *storeFileIdentifiers;
NSMutableArray *availableServers;
NSMutableArray *discoveredServers;
+ NSMutableArray *resolvedServices;
+ NSMutableArray *openConnections;
+
+ NSNetService *registeredService;
+
ServerBrowser *_serviceBrowser;
- BLIPConnection *_connection;
+// BLIPConnection *_connection;
NSInteger majorVersionNumber;
NSInteger minorVersionNumber;
@@ -154,18 +159,23 @@ typedef enum {
ZSyncServerAction serverAction;
NSLock *lock;
+ NSLock *serviceResolutionLock;
}
@property (nonatomic, assign) ZSyncServerAction serverAction;
@property (nonatomic, retain) ServerBrowser *serviceBrowser;
-@property (nonatomic, retain) BLIPConnection *connection;
-//@property (nonatomic, assign) BLIPConnection *connection;
+@property (nonatomic, retain) NSMutableArray *openConnections;
+@property (nonatomic, retain) NSNetService *registeredService;
+// @property (nonatomic, retain) BLIPConnection *connection;
+// @property (nonatomic, assign) BLIPConnection *connection;
@property (nonatomic, assign) NSInteger majorVersionNumber;
@property (nonatomic, assign) NSInteger minorVersionNumber;
@property (nonatomic, copy) NSString *passcode;
@property (retain) NSMutableArray *availableServers;
@property (retain) NSMutableArray *discoveredServers;
+@property (retain) NSMutableArray *resolvedServices;
@property (retain) NSLock *lock;
+@property (retain) NSLock *serviceResolutionLock;
@property (nonatomic, retain) NSMutableArray *storeFileIdentifiers;
@property (nonatomic, retain) NSMutableDictionary *receivedFileLookupDictionary;
@@ -180,7 +190,7 @@ typedef enum {
- (void)requestSync;
- (void)stopRequestingSync;
- (void)requestPairing:(ZSyncService *)server;
-//- (void)authenticatePairing:(NSString *)code;
+// - (void)authenticatePairing:(NSString *)code;
- (void)cancelPairing;
- (void)disconnectPairing;
Oops, something went wrong.

0 comments on commit dd27b15

Please sign in to comment.