8 import socketserver
as SocketServer
12 TCP Socket server for rosbridge 19 client_count_pub =
None 22 incoming_buffer = 65536
26 fragment_timeout = 600
28 delay_between_messages = 0
29 max_message_size =
None 30 unregister_timeout = 10.0
31 bson_only_mode =
False 50 self.protocol.log(
"info",
"connected. " + str(cls.
clients_connected) +
" client total.")
51 except Exception
as exc:
52 rospy.logerr(
"Unable to accept incoming connection. Reason: %s", str(exc))
59 packet = self.request.recv(n - len(data))
67 BSON_LENGTH_IN_BYTES = 4
68 raw_msglen = self.
recvall(BSON_LENGTH_IN_BYTES)
71 msglen = struct.unpack(
'i', raw_msglen)[0]
74 data = self.
recvall(msglen - BSON_LENGTH_IN_BYTES)
77 data = raw_msglen + data
84 self.protocol.incoming(data)
89 Listen for TCP messages 103 if data.strip() ==
'':
105 elif len(data.strip()) > 0:
106 self.protocol.incoming(data.strip(
''))
109 except Exception
as e:
111 self.protocol.log(
"debug",
"socket connection timed out! (ignore warning if client is only listening..)")
115 Called when TCP connection finishes 119 self.protocol.finish()
122 self.protocol.log(
"info",
"disconnected. " + str(cls.
clients_connected) +
" client total." )
126 Callback from rosbridge 128 self.request.sendall(message)
int delay_between_messages
def send_message(self, message=None)