diff options
| -rw-r--r-- | consumer.py | 29 | 
1 files changed, 16 insertions, 13 deletions
| diff --git a/consumer.py b/consumer.py index 31fd581..8c577c8 100644 --- a/consumer.py +++ b/consumer.py @@ -1,3 +1,6 @@ +""" This module provide a thread reading the events we need to send to the endpoint.
 +"""
 +
  import time
  import abc
  from threading import Thread
 @@ -11,7 +14,7 @@ from interfaces.message import ISocketMessage, Debug  @interface.implementer(ISocketMessage)
  class Mapping():
 -    """ Send an event requesting a layer change to the endpoint.
 +    """ Message requesting a layer change to the endpoint.
      """
      def __init__(self, message):
 @@ -120,21 +123,21 @@ class SocketMessageConsumer(EventConsummer):      def _process_layer(self, message) -> None:
          mapping, name = message
 -        if mapping == self._last_mapping:
 -            return
 -        self._last_mapping = mapping
 -
          configuration = component.getUtility(IConfiguration)
 -        if isinstance(mapping, dict):
 -            self._endpoint.send(mapping)
 -        elif isinstance(mapping, str):
 -            layer = configuration.get(mapping, None)
 -            if layer is not None:
 -                self._endpoint.send(layer)
 -
 +        if mapping != self._last_mapping:
 +            self._last_mapping = mapping
 +
 +            if isinstance(mapping, dict):
 +                self._endpoint.send(mapping)
 +            elif isinstance(mapping, str):
 +                layer = configuration.get(mapping, None)
 +                if layer is not None:
 +                    self._endpoint.send(layer)
 +
 +        # Even if the mapping is the same and does not need to be updated, we
 +        # may need to associate this new layer with another application.
          if name is not None:
              # We received a name to associate the configuration with.
 -            # Register the element in the configuration
              configuration[name] = mapping
              for key in mapping.keys():
                  # We do not want to log the keycode sent to the keyboard, only
 | 
