diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2025-05-07 11:31:20 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2025-07-07 08:32:41 +0200 |
commit | bae4e80500b552f7b3658a1a6a158fef02047f58 (patch) | |
tree | 1f8ea0764cce5b32b8cc2178a20211b3c993e7ff /socketserver.py | |
parent | 4bf1c1ffe795a1d28a543a20cc3771a30a090b89 (diff) |
Remove the existing handler (and unused) in socketserver
Diffstat (limited to 'socketserver.py')
-rw-r--r-- | socketserver.py | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/socketserver.py b/socketserver.py index eb7d4fc..b2234bc 100644 --- a/socketserver.py +++ b/socketserver.py @@ -18,7 +18,8 @@ from typing import Callable from zope import component
from interfaces import desktopEvent
-from interfaces.message import Debug, ISocketMessage
+from interfaces.message import Debug
+from consumer import Mapping # Event used to send the mapping change request
@dataclass
class waitEvent:
@@ -34,9 +35,8 @@ actions = { "layout" : lambda x : x,
}
-from consumer import Mapping # Event used to send the mapping change request
-class Handler(object):
+class Handler():
""" Listen the incomming connexions and dispatch them into the connexion
object """
@@ -45,7 +45,7 @@ class Handler(object): """
super().__init__()
self.sel = selectors.DefaultSelector()
- component.provideHandler(self.sendMessage)
+ #component.provideHandler(self.sendMessage)
self.socket = socket.socket()
self.socket.bind((configuration["host"], int(configuration["port"])))
@@ -67,18 +67,18 @@ class Handler(object): self.connexions = []
- @component.adapter(ISocketMessage)
- def sendMessage(self, content:ISocketMessage) -> None:
- """ Send a message to all the sockets connected to the server
- """
- c = sendEvent(message = content.content)
- c.callback = self._send
- map = self.sel.get_map()
- for value in list(map.values())[:]:
- if value.fileobj == self.socket:
- # Ignore the main connexion, keep it only in accept mode.
- continue
- self.sel.modify(value.fileobj, selectors.EVENT_WRITE, c)
+ #@component.adapter(ISocketMessage)
+ #def sendMessage(self, content:ISocketMessage) -> None:
+ # """ Send a message to all the sockets connected to the server
+ # """
+ # c = sendEvent(message = content.content)
+ # c.callback = self._send
+ # map = self.sel.get_map()
+ # for value in list(map.values())[:]:
+ # if value.fileobj == self.socket:
+ # # Ignore the main connexion, keep it only in accept mode.
+ # continue
+ # self.sel.modify(value.fileobj, selectors.EVENT_WRITE, c)
def update(self):
""" Read the status for all the sockets, if they are available.
@@ -137,6 +137,7 @@ class Handler(object): def _send(self:object, conn:socket, mask:int, text) -> None:
""" Internal method used to dispatch the message to the socket. """
+
try:
conn.sendall(bytes(text , "utf-8"))
except:
@@ -145,5 +146,7 @@ class Handler(object): self._switch_read(conn)
def close(self, conn):
+ """ Close all the existing connexions
+ """
self.sel.unregister(conn)
conn.close()
|