py-libp2p/libp2p/network/notifee_interface.py

55 lines
1.7 KiB
Python
Raw Normal View History

2019-08-01 06:00:12 +08:00
from abc import ABC, abstractmethod
2019-07-29 12:42:13 +08:00
from typing import TYPE_CHECKING
2019-03-01 07:12:09 +08:00
2019-07-28 14:06:29 +08:00
from multiaddr import Multiaddr
from libp2p.network.connection.net_connection_interface import INetConn
2019-07-28 22:30:51 +08:00
from libp2p.network.stream.net_stream_interface import INetStream
2019-07-29 12:42:13 +08:00
if TYPE_CHECKING:
2019-08-08 14:22:06 +08:00
from .network_interface import INetwork # noqa: F401
2019-07-29 12:42:13 +08:00
2019-07-28 14:06:29 +08:00
2019-03-01 07:12:09 +08:00
class INotifee(ABC):
@abstractmethod
2019-08-01 06:00:12 +08:00
async def opened_stream(self, network: "INetwork", stream: INetStream) -> None:
2019-03-01 07:12:09 +08:00
"""
:param network: network the stream was opened on
:param stream: stream that was opened
"""
@abstractmethod
2019-08-01 06:00:12 +08:00
async def closed_stream(self, network: "INetwork", stream: INetStream) -> None:
2019-03-01 07:12:09 +08:00
"""
:param network: network the stream was closed on
:param stream: stream that was closed
"""
@abstractmethod
async def connected(self, network: "INetwork", conn: INetConn) -> None:
2019-03-01 07:12:09 +08:00
"""
:param network: network the connection was opened on
:param conn: connection that was opened
"""
@abstractmethod
async def disconnected(self, network: "INetwork", conn: INetConn) -> None:
2019-03-01 07:12:09 +08:00
"""
:param network: network the connection was closed on
:param conn: connection that was closed
"""
@abstractmethod
2019-08-01 06:00:12 +08:00
async def listen(self, network: "INetwork", multiaddr: Multiaddr) -> None:
2019-03-01 07:12:09 +08:00
"""
:param network: network the listener is listening on
:param multiaddr: multiaddress listener is listening on
"""
@abstractmethod
2019-08-01 06:00:12 +08:00
async def listen_close(self, network: "INetwork", multiaddr: Multiaddr) -> None:
2019-03-01 07:12:09 +08:00
"""
:param network: network the connection was opened on
:param multiaddr: multiaddress listener is no longer listening on
"""