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. Close the underlying transport.
""" """
@abc.abstractmethod
def is_connected(self):
"""
Check if the underlying transport is connected.
"""
@abc.abstractmethod @abc.abstractmethod
def onDisconnect(self): def onDisconnect(self):
""" """

View File

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