def __init__(self, socket=None, encoding='utf-8'): _Channel.__init__(self, socket) # Set our prefix to an empty string. This is prepended to all sent # commands, and useful for servers. self.prefix = '' self.encoding = encoding # Read lines at once. self.read_delimiter = '\n'
def __init__(self, socket, server): """ Initialises the connection. Args: socket: A pre-existing socket that this channel should wrap. server: The server to which this channel is connected. Note: socket and parent arguments are non-optional because they are determined by the server. """ Channel.__init__(self, socket) self.server = server
def __init__(self, ConnectionClass=None): """ Initialises the server. Args: ConnectionClass: The class to use to wrap newly connected sockets. Optional. """ Channel.__init__(self) # Sets instance attribute, NOT class attribute. if ConnectionClass: self.ConnectionClass = ConnectionClass # A dictionary mapping file descriptors to channels. self.channels = weakref.WeakValueDictionary()