2018-10-27 04:16:24 +08:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
2018-11-13 02:02:49 +08:00
|
|
|
|
2018-10-27 04:16:24 +08:00
|
|
|
class IListener(ABC):
|
|
|
|
|
2018-10-27 06:06:56 +08:00
|
|
|
@abstractmethod
|
2019-07-10 19:33:38 +08:00
|
|
|
def listen(self, maddr):
|
2018-10-27 04:16:24 +08:00
|
|
|
"""
|
|
|
|
put listener in listening mode and wait for incoming connections
|
2019-07-10 19:33:38 +08:00
|
|
|
:param maddr: multiaddr of peer
|
2018-10-27 04:16:24 +08:00
|
|
|
:return: return True if successful
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def get_addrs(self):
|
|
|
|
"""
|
|
|
|
retrieve list of addresses the listener is listening on
|
|
|
|
:return: return list of addrs
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def close(self, options=None):
|
|
|
|
"""
|
|
|
|
close the listener such that no more connections
|
|
|
|
can be open on this transport instance
|
|
|
|
:param options: optional object potential with timeout
|
|
|
|
a timeout value in ms that fires and destroy all connections
|
|
|
|
:return: return True if successful
|
|
|
|
"""
|