refactor: rename EndpointBase to SocketBase

Because 'endpoint' is also used in the messages, the name 'socket' is more descriptive.

ref: N25B-168
This commit is contained in:
Twirre Meulenbelt
2025-10-09 16:24:31 +02:00
parent 23805812d5
commit e9c6b918e0
4 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,38 @@
from abc import ABCMeta
class SocketBase(object):
__metaclass__ = ABCMeta
name = None
socket = None
def __init__(self, name):
"""
:param name: The name of the endpoint.
:type name: str
"""
self.name = name
self.socket = None
def create_socket(self, zmq_context, socket_type, port):
"""
Create a ZeroMQ socket.
:param zmq_context: The ZeroMQ context to use.
:type zmq_context: zmq.Context
:param socket_type: The type of socket to create. Use zmq constants, e.g. zmq.SUB or zmq.REP.
:type socket_type: int
:param port: The port to use.
:type port: int
"""
self.socket = zmq_context.socket(socket_type)
self.socket.connect("tcp://localhost:{}".format(port))
def close(self):
"""Close the ZeroMQ socket."""
if not self.socket: return
self.socket.close()
self.socket = None