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:
@@ -1,5 +1,4 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import zmq
|
||||
|
||||
@@ -17,32 +16,10 @@ class ActuationReceiver(ReceiverBase):
|
||||
:param port: The port to use.
|
||||
:type port: int
|
||||
"""
|
||||
super(ActuationReceiver, self).__init__("actuation", "json")
|
||||
self.create_socket(zmq_context, zmq.SUB, port)
|
||||
self.socket.setsockopt_string(zmq.SUBSCRIBE, u"") # Subscribe to all topics
|
||||
self._qi_session = self._get_session()
|
||||
super(ActuationReceiver, self).__init__("actuation")
|
||||
self.create_socket(zmq_context, zmq.SUB, port, options=[(zmq.SUBSCRIBE, u"")])
|
||||
self._tts_service = None
|
||||
|
||||
@staticmethod
|
||||
def _get_session():
|
||||
if "--qi-url" not in sys.argv:
|
||||
logging.info("No Qi URL argument given. Running in stand-alone mode.")
|
||||
return None
|
||||
|
||||
try:
|
||||
import qi
|
||||
except ImportError:
|
||||
logging.info("Unable to import qi. Running in stand-alone mode.")
|
||||
return None
|
||||
|
||||
try:
|
||||
app = qi.Application()
|
||||
app.start()
|
||||
return app.session
|
||||
except RuntimeError:
|
||||
logging.info("Unable to connect to the robot. Running in stand-alone mode.")
|
||||
return None
|
||||
|
||||
def _handle_speech(self, message):
|
||||
text = message.get("data")
|
||||
if not text:
|
||||
|
||||
Reference in New Issue
Block a user