@@ -25,10 +25,6 @@ def check_clients_ok():
2525 else :
2626 client ['check_ok' ] = True
2727
28- def get_id (host , port ):
29- return 'client_{}_{}' .format (host , port )
30-
31-
3228@app .route ('/' )
3329def index ():
3430 check_clients_ok ()
@@ -60,7 +56,7 @@ def fake_data():
6056 client = random .choice (client_types )
6157 status = random .choice (statuses )
6258 check_ok = random .choice ([True , False ])
63- _id = 'client_127.0.0.1_ {}' .format (port )
59+ _id = 'fake_client_ {}' .format (port )
6460 data = {
6561 'client_type' : client ,
6662 '_id' : _id ,
@@ -87,7 +83,7 @@ def keep_alive():
8783 data = json .loads (request .data )
8884 host = request .remote_addr
8985 port = data ['port' ]
90- _id = get_id ( host , port )
86+ _id = data [ '_id' ]
9187 if _id not in global_state ['clients' ]:
9288 global_state ['clients' ][_id ] = {
9389 'joined_at' : datetime .now ().strftime ('%Y-%m-%d %H:%m' ),
@@ -118,7 +114,7 @@ def get_state():
118114 host = request .remote_addr
119115 data = json .loads (request .data )
120116 port = data ['port' ]
121- _id = get_id ( host , port )
117+ _id = data [ '_id' ]
122118 if _id not in global_state ['clients' ]:
123119 global_state ['clients' ][_id ] = {
124120 'joined_at' : datetime .now ().strftime ('%Y-%m-%d %H:%m' ),
0 commit comments