Browse Source

Add reconnect with same session ID to iOS library

Amir Khan 8 years ago
parent
commit
4af0e9b5fd

+ 13 - 0
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.h

@@ -331,6 +331,19 @@ Swift: @code func onInternetReachabilityChanged(_ currentReachability: Reachabil
  */
  */
 - (BOOL)start:(BOOL)ifNeeded;
 - (BOOL)start:(BOOL)ifNeeded;
 
 
+
+/*!
+ Force stops the tunnel and reconnects with the current session ID.
+ Retuns with FALSE immediately if no session ID has already been generated.
+
+ @note On the first connection `start:` method should always be used to generate a
+ session ID.
+
+ @return TRUE if the connection start was successful, FALSE otherwise.
+ Swift: @code func startWithCurrentSessionID() @endcode
+ */
+- (BOOL)stopAndReconnectWithCurrentSessionID;
+
 /*!
 /*!
  Stop the tunnel (regardless of its current connection state).
  Stop the tunnel (regardless of its current connection state).
  Swift: @code func stop() @endcode
  Swift: @code func stop() @endcode

+ 11 - 0
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

@@ -149,6 +149,17 @@
     return [self start];
     return [self start];
 }
 }
 
 
+// See comment in header
+- (BOOL)stopAndReconnectWithCurrentSessionID {
+
+    // Proceed only if a session ID has alreaby been generated.
+    if (self.sessionID == nil) {
+        return FALSE;
+    }
+
+    return [self start];
+}
+
 /*!
 /*!
  Start the tunnel. If the tunnel is already started it will be stopped first.
  Start the tunnel. If the tunnel is already started it will be stopped first.
  Assumes self.sessionID has been initialized -- i.e., assumes that
  Assumes self.sessionID has been initialized -- i.e., assumes that