refactor: use new port negotiation style

As changed in the API document, this now uses the new port negotiation style.

ref: N25B-168
This commit is contained in:
Twirre Meulenbelt
2025-10-16 17:22:04 +02:00
parent e12d88726d
commit 23c3379bfb
8 changed files with 43 additions and 69 deletions

View File

@@ -2,8 +2,6 @@ from abc import ABCMeta
import zmq
from robot_interface.utils import zmq_socket_type_int_to_str, zmq_socket_type_complement
class SocketBase(object):
__metaclass__ = ABCMeta
@@ -11,16 +9,12 @@ class SocketBase(object):
name = None
socket = None
def __init__(self, name, data_type):
def __init__(self, identifier):
"""
:param name: The name of the endpoint.
:type name: str
:param data_type: The data type of the endpoint, e.g. "json", "binary", "text", etc.
:type data_type: str
:param identifier: The identifier of the endpoint.
:type identifier: str
"""
self.name = name
self.data_type = data_type
self.identifier = identifier
self.port = None # Set later by `create_socket`
self.socket = None # Set later by `create_socket`
self.bound = None # Set later by `create_socket`
@@ -71,9 +65,7 @@ class SocketBase(object):
:rtype: dict
"""
return {
"name": self.name,
"id": self.identifier,
"port": self.port,
"pattern": zmq_socket_type_int_to_str[zmq_socket_type_complement[self.socket.getsockopt(zmq.TYPE)]],
"data_type": self.data_type,
"bind": not self.bound
}