diff --git a/mopidy/frontends/mpd/dispatcher.py b/mopidy/frontends/mpd/dispatcher.py index 2eb0805c..e513a4d1 100644 --- a/mopidy/frontends/mpd/dispatcher.py +++ b/mopidy/frontends/mpd/dispatcher.py @@ -25,10 +25,10 @@ class MpdDispatcher(object): # XXX Consider merging MpdDispatcher into MpdSession - def __init__(self): + def __init__(self, session=None): self.command_list = False self.command_list_ok = False - self.context = MpdContext(self) + self.context = MpdContext(self, session=session) def handle_request(self, request, command_list_index=None): """Dispatch incoming requests to the correct handler.""" @@ -91,8 +91,12 @@ class MpdContext(object): #: The current :class:`MpdDispatcher`. dispatcher = None - def __init__(self, dispatcher): + #: The current :class:`mopidy.frontends.mpd.session.MpdSession`. + session = None + + def __init__(self, dispatcher, session=None): self.dispatcher = dispatcher + self.session = session self._backend = None self._mixer = None diff --git a/mopidy/frontends/mpd/session.py b/mopidy/frontends/mpd/session.py index 6308e66e..4ac09a68 100644 --- a/mopidy/frontends/mpd/session.py +++ b/mopidy/frontends/mpd/session.py @@ -22,7 +22,7 @@ class MpdSession(asynchat.async_chat): self.input_buffer = [] self.authenticated = False self.set_terminator(LINE_TERMINATOR.encode(ENCODING)) - self.dispatcher = MpdDispatcher() + self.dispatcher = MpdDispatcher(session=self) def start(self): """Start a new client session."""