parameters: (self, serverList,
                  successCallback = None, successArgs = [],
                  failureCallback = None, failureArgs = [])
docstring: Attempts to establish a connection to the server.  May return
          before the connection is established.  The two callbacks
          represent the two functions to call (and their arguments) on
          success or failure, respectively.  The failure callback also
          gets one additional parameter, which will be passed in first:
          the return status code giving reason for failure, if it is
          known.
docstring_summary: Attempts to establish a connection to the server.  May return
          before the connection is established.  The two callbacks
          represent the two functions to call (and their arguments) on
          success or failure, respectively.  The failure callback also
          gets one additional parameter, which will be passed in first:
          the return status code giving reason for failure, if it is
          known.
docstring_tokens: Attempts to establish a connection to the server . May return before the connection is established . The two callbacks represent the two functions to call ( and their arguments ) on success or failure respectively . The failure callback also gets one additional parameter which will be passed in first : the return status code giving reason for failure if it is known .
function: def connect(self, serverList,
                  successCallback = None, successArgs = [],
                  failureCallback = None, failureArgs = []):
          """
          Attempts to establish a connection to the server.  May return
          before the connection is established.  The two callbacks
          represent the two functions to call (and their arguments) on
          success or failure, respectively.  The failure callback also
          gets one additional parameter, which will be passed in first:
          the return status code giving reason for failure, if it is
          known.
          """
  
          ## if self.recorder and self.recorder.isPlaying():
  
          ##     # If we have a recorder and it's already in playback mode,
          ##     # don't actually attempt to connect to a gameserver since
          ##     # we don't need to.  Just let it play back the data.
          ##     self.notify.info("Not connecting to gameserver; using playback data instead.")
  
          ##     self.connectHttp = 1
          ##     self.tcpConn = SocketStreamRecorder()
          ##     self.recorder.addRecorder('gameserver', self.tcpConn)
  
          ##     self.startReaderPollTask()
          ##     if successCallback:
          ##         successCallback(*successArgs)
          ##     return
  
          hasProxy = 0
          if self.checkHttp():
              proxies = self.http.getProxiesForUrl(serverList[0])
              hasProxy = (proxies != 'DIRECT')
  
          if hasProxy:
              self.notify.info("Connecting to gameserver via proxy list: %s" % (proxies))
          else:
              self.notify.info("Connecting to gameserver directly (no proxy).")
  
          #Redefine the connection to http or net in the default case
  
          self.bootedIndex = None
          self.bootedText = None
          if self.connectMethod == self.CM_HTTP:
              # In the HTTP case, we can't just iterate through the list
              # of servers, because each server attempt requires
              # spawning a request and then coming back later to check
              # the success or failure.  Instead, we start the ball
              # rolling by calling the connect callback, which will call
              # itself repeatedly until we establish a connection (or
              # run out of servers).
  
              ch = self.http.makeChannel(0)
              self.httpConnectCallback(
                      ch, serverList, 0,
                      successCallback, successArgs,
                      failureCallback, failureArgs)
          elif self.connectMethod == self.CM_NET or (not hasattr(self,"connectNative")):
              # Try each of the servers in turn.
              for url in serverList:
                  self.notify.info("Connecting to %s via NET interface." % (url))
                  if self.tryConnectNet(url):
                      self.startReaderPollTask()
                      if successCallback:
                          successCallback(*successArgs)
                      return
  
              # Failed to connect.
              if failureCallback:
                  failureCallback(0, '', *failureArgs)
          elif self.connectMethod == self.CM_NATIVE:
              for url in serverList:
                  self.notify.info("Connecting to %s via Native interface." % (url))
                  if self.connectNative(url):
                      self.startReaderPollTask()
                      if successCallback:
                          successCallback(*successArgs)
                      return
  
              # Failed to connect.
              if failureCallback:
                  failureCallback(0, '', *failureArgs)
          else:
              print("uh oh, we aren't using one of the tri-state CM variables")
              failureCallback(0, '', *failureArgs)
function_tokens: def connect ( self , serverList , successCallback = None , successArgs = [ ] , failureCallback = None , failureArgs = [ ] ) : ## if self.recorder and self.recorder.isPlaying(): ##     # If we have a recorder and it's already in playback mode, ##     # don't actually attempt to connect to a gameserver since ##     # we don't need to.  Just let it play back the data. ##     self.notify.info("Not connecting to gameserver; using playback data instead.") ##     self.connectHttp = 1 ##     self.tcpConn = SocketStreamRecorder() ##     self.recorder.addRecorder('gameserver', self.tcpConn) ##     self.startReaderPollTask() ##     if successCallback: ##         successCallback(*successArgs) ##     return hasProxy = 0 if self . checkHttp ( ) : proxies = self . http . getProxiesForUrl ( serverList [ 0 ] ) hasProxy = ( proxies != 'DIRECT' ) if hasProxy : self . notify . info ( "Connecting to gameserver via proxy list: %s" % ( proxies ) ) else : self . notify . info ( "Connecting to gameserver directly (no proxy)." ) #Redefine the connection to http or net in the default case self . bootedIndex = None self . bootedText = None if self . connectMethod == self . CM_HTTP : # In the HTTP case, we can't just iterate through the list # of servers, because each server attempt requires # spawning a request and then coming back later to check # the success or failure.  Instead, we start the ball # rolling by calling the connect callback, which will call # itself repeatedly until we establish a connection (or # run out of servers). ch = self . http . makeChannel ( 0 ) self . httpConnectCallback ( ch , serverList , 0 , successCallback , successArgs , failureCallback , failureArgs ) elif self . connectMethod == self . CM_NET or ( not hasattr ( self , "connectNative" ) ) : # Try each of the servers in turn. for url in serverList : self . notify . info ( "Connecting to %s via NET interface." % ( url ) ) if self . tryConnectNet ( url ) : self . startReaderPollTask ( ) if successCallback : successCallback ( * successArgs ) return # Failed to connect. if failureCallback : failureCallback ( 0 , '' , * failureArgs ) elif self . connectMethod == self . CM_NATIVE : for url in serverList : self . notify . info ( "Connecting to %s via Native interface." % ( url ) ) if self . connectNative ( url ) : self . startReaderPollTask ( ) if successCallback : successCallback ( * successArgs ) return # Failed to connect. if failureCallback : failureCallback ( 0 , '' , * failureArgs ) else : print ( "uh oh, we aren't using one of the tri-state CM variables" ) failureCallback ( 0 , '' , * failureArgs )