restructured raw connection

This commit is contained in:
Alex Haynes
2018-11-11 12:17:12 -05:00
parent 7d4227f269
commit a785876c16
3 changed files with 32 additions and 20 deletions

View File

@ -3,14 +3,20 @@ from .raw_connection_interface import IRawConnection
class RawConnection(IRawConnection):
def __init__(self, ip, port):
def __init__(self, ip, port, reader, writer):
self.conn_ip = ip
self.conn_port = port
self.reader, self.writer = self.open_connection()
self.reader = reader
self.writer = writer
async def open_connection(self):
"""
opens a connection on self.ip and self.port
:return: a raw connection
"""
return await asyncio.open_connection(self.conn_ip, self.conn_port)
# def __init__(self, ip, port):
# self.conn_ip = ip
# self.conn_port = port
# self.reader, self.writer = self.open_connection()
# async def open_connection(self):
# """
# opens a connection on self.ip and self.port
# :return: a raw connection
# """
# return await asyncio.open_connection(self.conn_ip, self.conn_port)

View File

@ -6,10 +6,10 @@ class IRawConnection(ABC):
open_connection should return such a connection
"""
@abstractmethod
async def open_connection(self):
"""
opens a connection on ip and port
:return: a raw connection
"""
pass
# @abstractmethod
# async def open_connection(self):
# """
# opens a connection on ip and port
# :return: a raw connection
# """
# pass