def __init__(self, server, client_socket, client_socket_address): asynchat.async_chat.__init__(self, sock=client_socket) self.server = server self.client_address = client_socket_address[0] self.client_port = client_socket_address[1] self.input_buffer = [] self.authenticated = False self.set_terminator(LINE_TERMINATOR.encode(ENCODING)) self.dispatcher = MpdDispatcher(session=self) self.send_response([u'OK MPD %s' % VERSION])
def __init__(self, server, client_socket, client_socket_address, core_queue): asynchat.async_chat.__init__(self, sock=client_socket) self.server = server self.client_address = client_socket_address[0] self.client_port = client_socket_address[1] self.core_queue = core_queue self.input_buffer = [] self.authenticated = False self.set_terminator(LINE_TERMINATOR.encode(ENCODING))
def send_response(self, response): """ Format a response from the MPD command handlers and send it to the client. """ if response: response = LINE_TERMINATOR.join(response) logger.debug(u'Response to [%s]:%s: %s', self.client_address, self.client_port, indent(response)) response = u'%s%s' % (response, LINE_TERMINATOR) data = response.encode(ENCODING) self.push(data)
def handle_response(self, response): """Handle response from the MPD frontend.""" self.send_response(LINE_TERMINATOR.join(response))