@@ -36,7 +36,8 @@ def __init__(self, controller):
3636 self .controller = controller
3737 self .dojo_broker = self .controller .settings_manager .get_dojo_broker ()
3838 self .dojo_port = self .controller .settings_manager .get_dojo_port ()
39- self .dojo_mob_station_name = self .controller .settings_manager .get_dojo_mob_station_name () + uuid .uuid4 ().__str__ ()
39+ self .dojo_station_uuid = uuid .uuid4 ().__str__ ()
40+ self .dojo_mob_station_name = self .controller .settings_manager .get_dojo_mob_station_name ()
4041 self .dojo_session_id = self .controller .settings_manager .get_dojo_session_id ()
4142 self .dojo_topic_root = self .controller .settings_manager .get_dojo_topic_root ()
4243 self .controller .mobber_manager .subscribe_to_mobber_list_change (self .publish_mobber_list_changes )
@@ -51,12 +52,14 @@ def say_hello(self):
5152 def publish_time_change (self , time_string , minutes , seconds , origin_station_name = None ):
5253 topic = self .generate_topic (TIME_CHANGE )
5354 station_name = self .dojo_mob_station_name
55+ station_uuid = self .dojo_station_uuid
5456 if origin_station_name is not None :
5557 return
5658 payload_dictionary = {
5759 "minutes" : minutes ,
5860 "seconds" : seconds ,
59- "station_name" : station_name
61+ "station_name" : station_name ,
62+ "station_uuid" : station_uuid
6063 }
6164 payload = json .dumps (payload_dictionary )
6265 self .publish (topic , payload )
@@ -88,30 +91,31 @@ def on_message(self, client, userdata, msg):
8891 topic_parts = msg .topic .split ('/' )
8992 topic_root = topic_parts [0 ]
9093 session_id = topic_parts [1 ]
91- station_name = topic_parts [2 ]
92- message_type = topic_parts [3 ]
93- print ("on_message" ,msg .topic )
94- self .switch_statement_dictionary_trick (station_name , message_type , msg .payload )
94+ station_uuid = topic_parts [2 ]
95+ station_name = topic_parts [3 ]
96+ message_type = topic_parts [4 ]
97+ print ("on_message" ,msg .topic ,"station_uuid" ,station_uuid )
98+ self .switch_statement_dictionary_trick (station_uuid ,station_name , message_type , msg .payload )
9599
96- def switch_statement_dictionary_trick (self , station_name , message_type , payload ):
97- self .switch_dictionary [message_type ](station_name , message_type , payload )
100+ def switch_statement_dictionary_trick (self , station_uuid , station_name , message_type , payload ):
101+ self .switch_dictionary [message_type ](station_uuid , station_name , message_type , payload )
98102
99- def sub_mobber_list (self , station_name , message_type , payload ):
100- if not station_name == self .dojo_mob_station_name :
103+ def sub_mobber_list (self , station_uuid , station_name , message_type , payload ):
104+ if not station_uuid == self .dojo_station_uuid :
101105 payload_dictionary = json .loads (payload .decode ("utf-8" ))
102106 mobber_list = payload_dictionary ["mobber_list" ]
103107 print ("sub_mobber_list" ,mobber_list )
104108 self .controller .mobber_manager .set_mobber_list (mobber_list )
105109
106110 def generate_topic (self , message_type ):
107- topic = "{}/{}/{}/{}" .format (self .dojo_topic_root , self .dojo_session_id , self .dojo_mob_station_name ,
111+ topic = "{}/{}/{}/{}/{} " .format (self .dojo_topic_root , self .dojo_session_id , self . dojo_station_uuid , self .dojo_mob_station_name ,
108112 message_type )
109113 print ("generate_topic" ,topic )
110114 return topic
111115
112- def sub_time_change (self , station_name , message_type , payload ):
116+ def sub_time_change (self , station_uuid , station_name , message_type , payload ):
113117 print (payload )
114- if not station_name == self .dojo_mob_station_name :
118+ if not station_uuid == self .dojo_station_uuid :
115119 payload_dictionary = json .loads (payload .decode ("utf-8" ))
116120 minutes = payload_dictionary ["minutes" ]
117121 seconds = payload_dictionary ["seconds" ]
@@ -120,15 +124,15 @@ def sub_time_change(self, station_name, message_type, payload):
120124 self .controller .time_options_manager .minutes == minutes and self .controller .time_options_manager .seconds == seconds ):
121125 self .controller .time_options_manager .set_countdown_time (minutes , seconds , origin_station_name )
122126
123- def sub_say_hello (self , station_name , message_type , payload ):
124- if not station_name == self .dojo_mob_station_name :
127+ def sub_say_hello (self , station_uuid , station_name , message_type , payload ):
128+ if not station_uuid == self .dojo_station_uuid :
125129 if not self .other_stations .__contains__ (station_name ):
126130 self .other_stations .append (station_name )
127131 topic = self .generate_topic (SAY_HELLO )
128132 self .publish (topic , "" )
129133
130- def sub_start_timer (self , station_name , message_type , payload ):
131- if not station_name == self .dojo_mob_station_name :
134+ def sub_start_timer (self , station_uuid , station_name , message_type , payload ):
135+ if not station_uuid == self .dojo_station_uuid :
132136 self .controller .launch_transparent_countdown_if_blocking ()
133137
134138 def subscribe_to_dojo (self ):
0 commit comments