py-libp2p/transport/listener_interface.py

30 lines
829 B
Python
Raw Normal View History

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
2018-10-27 04:16:24 +08:00
def listen(self, multiaddr):
"""
put listener in listening mode and wait for incoming connections
:param multiaddr: multiaddr of peer
: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
"""