@@ -61,25 +61,11 @@ } _client = [client retain]; of_log(@"Logged in client: %@", _client); - [self sync]; - }]; -} - -- (void)sync -{ - [_client syncWithTimeout: 5 - block: ^ (id exception) { - if (exception != nil) { - of_log(@"Failed to sync: %@", exception); - [OFApplication terminateWithStatus: 1]; - } - - of_log(@"Synced"); - + [_client startSyncLoop]; [self fetchRoomList]; }]; } - (void)fetchRoomList @@ -108,25 +94,10 @@ } _roomID = [roomID copy]; of_log(@"Joined room %@", _roomID); - [self sync2]; - }]; -} - -- (void)sync2 -{ - [_client syncWithTimeout: 5 - block: ^ (id exception) { - if (exception != nil) { - of_log(@"Failed to sync: %@", exception); - [OFApplication terminateWithStatus: 1]; - } - - of_log(@"Synced"); - [self sendMessage]; }]; } - (void)sendMessage @@ -140,11 +111,15 @@ [OFApplication terminateWithStatus: 1]; } of_log(@"Message sent to %@", _roomID); - [self leaveRoom]; + of_log( + @"Waiting 5 seconds before leaving room and logging out"); + + [self performSelector: @selector(leaveRoom) + afterDelay: 5]; }]; } - (void)leaveRoom {