]> kaliko git repositories - python-musicpdaio.git/blobdiff - mpdaio/connection.py
Move protocol logic in the client
[python-musicpdaio.git] / mpdaio / connection.py
index d00f85af9755f81b84299dfe999ac624bb8f0e4c..f200bad7d85d1e923d245ff7eea2853ea6b4b160 100644 (file)
@@ -12,9 +12,6 @@ from collections import OrderedDict
 from types import TracebackType
 from typing import Any, List, Optional, Tuple, Type
 
-from .const import HELLO_PREFIX
-from .exceptions import MPDProtocolError
-
 try:  # Python 3.7
     base = contextlib.AbstractAsyncContextManager
 except AttributeError as err:
@@ -75,7 +72,6 @@ class ConnectionPool(base):
                         )
             #log.debug('Connected to %s:%s', host[0], host[1])
             connection = Connection(self, host, reader, writer)
-            await connection._hello()
             connections.append(connection)
 
         connection.in_use = True
@@ -140,7 +136,8 @@ class Connection(base):
         self._reader = reader
         self._writer = writer
         self._closed = False
-        self.auth = False
+        #: password command with the secret was sent
+        self.auth: bool = False
         self.in_use = False
         self.version: str | None = None
 
@@ -169,16 +166,6 @@ class Connection(base):
         except AttributeError:  # wait_closed is new in 3.7
             pass
 
-    async def _hello(self) -> None:
-        """Consume HELLO_PREFIX"""
-        self.in_use = True
-        data = await self.readuntil(b'\n')
-        rcv = data.decode('utf-8')
-        if not rcv.startswith(HELLO_PREFIX):
-            raise MPDProtocolError(f'Got invalid MPD hello: "{rcv}"')
-        log.debug('consumed hello prefix: %r', rcv)
-        self.version = rcv.split('\n')[0][len(HELLO_PREFIX):]
-
     def __getattr__(self, name: str) -> Any:
         """All unknown attributes are delegated to the reader and writer"""
         if self._closed or not self.in_use: