Beispiel #1
0
def gen_map():
    instance.gmutex.acquire()
    api.update_map_loc('alice', '40.442885', '-79.94263')
    api.update_map_loc('bob', '40.444885', '-79.94463')
    instance.gmutex.release()
    map_loc_str = instance.map_loc
    marker_list = []
    strs = map_loc_str.split(":")
    if len(strs) == 1:
        return
    for i in range(1, len(strs)):
        loc = strs[i]
        data = loc.split("#")
        marker_list.append([float(data[1]), float(data[2]), data[3]])
    gps_data = [marker_list[0][0], marker_list[0][1]]
    des = generate_map_and_desc(gps_data, marker_list)
    gui.update_image(instance.name + '_map.png')
Beispiel #2
0
def handle_message(data):
  strs = data.split(':')
  if strs[instance.MSGTYPE] == 'heartbeat':
    handle_heartbeat(strs)
  elif strs[instance.MSGTYPE] == 'joinreject':
    print 'Error! Join rejected'
    sys.exit(1)
  elif strs[instance.MSGTYPE] == 'mobilelocation':
    sender = strs[instance.SENDER]
    latitude = strs[3]
    longitude = strs[4]
    api.update_map_loc(sender, latitude, longitude)
  elif strs[instance.MSGTYPE] == 'textmsg':
    sender = strs[instance.SENDER]
    text = strs[3]
    api.received_text_msg(sender, text)
  else:
    print 'Error! Invalid message'