feat: client list for the server
This commit is contained in:
parent
da5ccfd4ef
commit
91c62785fd
@ -194,6 +194,7 @@ class ServerNetService(threading.Thread):
|
||||
self.pull = None
|
||||
self.state = 0
|
||||
self.factory = factory
|
||||
self.clients = []
|
||||
|
||||
|
||||
def listen(self, port=5560):
|
||||
@ -206,6 +207,7 @@ class ServerNetService(threading.Thread):
|
||||
|
||||
# Update all clients
|
||||
self.publisher = self.context.socket(zmq.PUB)
|
||||
# self.publisher.setsockopt(zmq.IDENTITY,b'SERVER')
|
||||
self.publisher.setsockopt(zmq.SNDHWM, 60)
|
||||
self.publisher.bind("tcp://*:{}".format(port+1))
|
||||
time.sleep(0.2)
|
||||
@ -240,32 +242,16 @@ class ServerNetService(threading.Thread):
|
||||
request = msg[1]
|
||||
|
||||
if request == b"SNAPSHOT_REQUEST":
|
||||
pass
|
||||
else:
|
||||
logger.info("Bad snapshot request")
|
||||
break
|
||||
# Sending snapshots
|
||||
for key, item in self._rep_store:
|
||||
self.snapshot.send(identity, zmq.SNDMORE)
|
||||
item.push(self.snapshot)
|
||||
|
||||
for key, item in self._rep_store:
|
||||
# Snapshot end
|
||||
self.snapshot.send(identity, zmq.SNDMORE)
|
||||
item.push(self.snapshot)
|
||||
|
||||
self.snapshot.send(identity, zmq.SNDMORE)
|
||||
RepCommand(owner='server',data='SNAPSHOT_END').push(self.snapshot)
|
||||
RepCommand(owner='server',data='SNAPSHOT_END').push(self.snapshot)
|
||||
|
||||
|
||||
# ordered_props = [(SUPPORTED_TYPES.index(k.split('/')[0]),k,v) for k, v in self.property_map.items()]
|
||||
# ordered_props.sort(key=itemgetter(0))
|
||||
|
||||
# for i, k, v in ordered_props:
|
||||
# logger.info(
|
||||
# "Sending {} snapshot to {}".format(k, identity))
|
||||
# self.request_sock.send(identity, zmq.SNDMORE)
|
||||
# v.send(self.request_sock)
|
||||
|
||||
# msg_end_snapshot = message.Message(key="SNAPSHOT_END", id=identity)
|
||||
# self.request_sock.send(identity, zmq.SNDMORE)
|
||||
# msg_end_snapshot.send(self.request_sock)
|
||||
# logger.info("done")
|
||||
|
||||
# Regular update routing (Clients / Client)
|
||||
if self.pull in socks:
|
||||
|
@ -81,7 +81,7 @@ class TestClient(unittest.TestCase):
|
||||
data_sample_key = client.register(SampleData())
|
||||
|
||||
#Waiting for server to receive the datas
|
||||
time.sleep(.2)
|
||||
time.sleep(.5)
|
||||
|
||||
rep_test_key = client2._rep_store[data_sample_key].uuid
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user