2019-03-01 08:11:04 +08:00
|
|
|
import asyncio
|
2019-03-01 07:12:09 +08:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
|
|
class INotifee(ABC):
|
|
|
|
|
|
|
|
@abstractmethod
|
2019-03-01 08:11:04 +08:00
|
|
|
async def opened_stream(self, network, stream):
|
2019-03-01 07:12:09 +08:00
|
|
|
"""
|
|
|
|
:param network: network the stream was opened on
|
|
|
|
:param stream: stream that was opened
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
2019-03-01 08:11:04 +08:00
|
|
|
async def closed_stream(self, network, stream):
|
2019-03-01 07:12:09 +08:00
|
|
|
"""
|
|
|
|
:param network: network the stream was closed on
|
|
|
|
:param stream: stream that was closed
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
2019-03-01 08:11:04 +08:00
|
|
|
async def connected(self, network, conn):
|
2019-03-01 07:12:09 +08:00
|
|
|
"""
|
|
|
|
:param network: network the connection was opened on
|
|
|
|
:param conn: connection that was opened
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
2019-03-01 08:11:04 +08:00
|
|
|
async def disconnected(self, network, conn):
|
2019-03-01 07:12:09 +08:00
|
|
|
"""
|
|
|
|
:param network: network the connection was closed on
|
|
|
|
:param conn: connection that was closed
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
2019-03-01 08:11:04 +08:00
|
|
|
async def listen(self, network, multiaddr):
|
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-03-01 08:11:04 +08:00
|
|
|
async def listen_close(self, network, multiaddr):
|
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
|
|
|
|
"""
|