Browse Source

prevent overlapping connect(); no client reconnect

pull/34/head
Rossen Georgiev 9 years ago
parent
commit
51344f3ac9
  1. 4
      steam/client/__init__.py
  2. 9
      steam/core/cm.py

4
steam/client/__init__.py

@ -105,10 +105,6 @@ class SteamClient(EventEmitter, FeatureBase):
self.emit("job_%d" % jobid, *args)
def _handle_disconnect(self, *args):
# only disconnect, reconnect has 1 arg
if self.logged_on and len(args) == 0:
gevent.spawn(self.connect)
self.username = None
self.logged_on = False
self.current_jobid = 0

9
steam/core/cm.py

@ -38,6 +38,7 @@ class CMClient(EventEmitter):
servers = None #: a instance of :class:`steam.core.cm.CMServerList`
current_server_addr = None #: (ip, port) tuple
_connecting = False
connected = False #: :class:`True` if connected to CM
channel_secured = False #: :class:`True` once secure channel handshake is complete
@ -72,6 +73,13 @@ class CMClient(EventEmitter):
def connect(self):
"""Initiate connection to CM. Blocks until we connect."""
if self.connected:
logger.debug("Connect called, but we are connected?")
return
if self._connecting:
logger.debug("Connect called, but we are already connecting.")
return
self._connecting = True
logger.debug("Connect initiated.")
@ -92,6 +100,7 @@ class CMClient(EventEmitter):
self.connected = True
self.emit("connected")
self._recv_loop = gevent.spawn(self._recv_messages)
self._connecting = False
def disconnect(self, reconnect=False, nodelay=False):
"""Close connection

Loading…
Cancel
Save