From 4bf1c1ffe795a1d28a543a20cc3771a30a090b89 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Tue, 6 May 2025 19:33:30 +0200 Subject: Added a dedicated thread for handling events sent to the endpoint --- socketserver.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'socketserver.py') diff --git a/socketserver.py b/socketserver.py index 74f0940..eb7d4fc 100644 --- a/socketserver.py +++ b/socketserver.py @@ -34,14 +34,14 @@ actions = { "layout" : lambda x : x, } +from consumer import Mapping # Event used to send the mapping change request + class Handler(object): """ Listen the incomming connexions and dispatch them into the connexion object """ - def __init__(self, configuration, layout_queue): + def __init__(self, configuration): """ Initialize the the socket server - - The layout_queue will be populated with all the elements received from the socket. """ super().__init__() self.sel = selectors.DefaultSelector() @@ -66,7 +66,6 @@ class Handler(object): self.connexions = [] - self.layout_queue = layout_queue @component.adapter(ISocketMessage) def sendMessage(self, content:ISocketMessage) -> None: @@ -130,11 +129,11 @@ class Handler(object): # As we have a name in the configuration to associate with, use # this name as a reference for title in self.application_name: - self.layout_queue.put((js, title)) + component.handle(Mapping((js, title))) else: # Associate the layout with the current window title = component.queryUtility(desktopEvent.IDesktop).getForegroundWindowTitle() - self.layout_queue.put((js, title)) + component.handle(Mapping((js, title))) def _send(self:object, conn:socket, mask:int, text) -> None: """ Internal method used to dispatch the message to the socket. """ -- cgit v1.2.3