def set_application(self, app, callback=None):
    '\n        Set ``CommandLineInterface`` instance for this connection.\n        (This can be replaced any time.)\n\n        :param cli: CommandLineInterface instance.\n        :param callback: Callable that takes the result of the CLI.\n        '
    assert isinstance(app, Application)
    assert ((callback is None) or callable(callback))
    self.cli = CommandLineInterface(application=app, eventloop=self.eventloop, output=self.vt100_output)
    self.callback = callback
    cb = self.cli.create_eventloop_callbacks()
    inputstream = InputStream(cb.feed_key)
    stdin_decoder_cls = getincrementaldecoder(self.encoding)
    stdin_decoder = [stdin_decoder_cls()]
    self.cli._is_running = True

    def data_received(data):
        " TelnetProtocolParser 'data_received' callback "
        assert isinstance(data, binary_type)
        try:
            result = stdin_decoder[0].decode(data)
            inputstream.feed(result)
        except UnicodeDecodeError:
            stdin_decoder[0] = stdin_decoder_cls()
            return ''

    def size_received(rows, columns):
        " TelnetProtocolParser 'size_received' callback "
        self.size = Size(rows=rows, columns=columns)
        cb.terminal_size_changed()
    self.parser = TelnetProtocolParser(data_received, size_received)
Set ``CommandLineInterface`` instance for this connection.
(This can be replaced any time.)

:param cli: CommandLineInterface instance.
:param callback: Callable that takes the result of the CLI.
def set_application(self, app, callback=None):
    '\n        Set ``CommandLineInterface`` instance for this connection.\n        (This can be replaced any time.)\n\n        :param cli: CommandLineInterface instance.\n        :param callback: Callable that takes the result of the CLI.\n        '
    assert isinstance(app, Application)
    assert ((callback is None) or callable(callback))
    self.cli = CommandLineInterface(application=app, eventloop=self.eventloop, output=self.vt100_output)
    self.callback = callback
    cb = self.cli.create_eventloop_callbacks()
    inputstream = InputStream(cb.feed_key)
    stdin_decoder_cls = getincrementaldecoder(self.encoding)
    stdin_decoder = [stdin_decoder_cls()]
    self.cli._is_running = True

    def data_received(data):
        " TelnetProtocolParser 'data_received' callback "
        assert isinstance(data, binary_type)
        try:
            result = stdin_decoder[0].decode(data)
            inputstream.feed(result)
        except UnicodeDecodeError:
            stdin_decoder[0] = stdin_decoder_cls()
            return 

    def size_received(rows, columns):
        " TelnetProtocolParser 'size_received' callback "
        self.size = Size(rows=rows, columns=columns)
        cb.terminal_size_changed()
    self.parser = TelnetProtocolParser(data_received, size_received)