ignore calling disconnect on session that isn't connected; add is_connected()

This commit is contained in:
Tobias Oberstein 2015-07-01 23:36:46 +02:00
parent 9ba652a53d
commit e6092d6546
2 changed files with 12 additions and 3 deletions

View File

@ -322,6 +322,12 @@ class ISession(object):
Close the underlying transport.
"""
@abc.abstractmethod
def is_connected(self):
"""
Check if the underlying transport is connected.
"""
@abc.abstractmethod
def onDisconnect(self):
"""

View File

@ -496,9 +496,12 @@ class ApplicationSession(BaseSession):
"""
if self._transport:
self._transport.close()
else:
# XXX or shall we just ignore this?
raise RuntimeError("No transport, but disconnect() called.")
def is_connected(self):
"""
Implements :func:`autobahn.wamp.interfaces.ISession.is_connected`
"""
return self._transport is not None
def onUserError(self, e, msg):
"""