py-libp2p/libp2p/transport/listener_interface.py
mhchia c61a06706a
Refactor interop tests and factories
- Add `close` and `disconnect` in `Host`
- Add `close` and `close_peer` in `Network`
- Change `IListener.close` to async, to await for server's closing
- Add factories for security transports, and modify `HostFactory`
2019-08-29 21:38:06 +08:00

29 lines
746 B
Python

from abc import ABC, abstractmethod
from typing import List
from multiaddr import Multiaddr
class IListener(ABC):
@abstractmethod
async def listen(self, maddr: Multiaddr) -> bool:
"""
put listener in listening mode and wait for incoming connections
:param maddr: multiaddr of peer
:return: return True if successful
"""
@abstractmethod
def get_addrs(self) -> List[Multiaddr]:
"""
retrieve list of addresses the listener is listening on
:return: return list of addrs
"""
@abstractmethod
async def close(self) -> None:
"""
close the listener such that no more connections
can be open on this transport instance
"""