def handle_STATESERVER_OBJECT_CHANGING_LOCATION(self, dgi, sender,
                                                 recipients):
     print("handle_STATESERVER_OBJECT_CHANGING_LOCATION", sender,
           recipients)
     do_id = dgi.read_uint32()
     new_parent = dgi.read_uint32()
     new_zone = dgi.read_uint32()
     old_parent = dgi.read_uint32()
     old_zone = dgi.read_uint32()
     if parent_zone_to_location(
             new_parent,
             new_zone) in self.distobj_interests_location_to_do_id.keys():
         interested_distobjs = self.distobj_interests_location_to_do_id[
             parent_zone_to_location(new_parent, new_zone)]
         for distobj in interested_distobjs:
             self.distributed_objects[
                 distobj].interest_changing_location_enter(
                     sender, do_id, new_parent, new_zone, old_parent,
                     old_zone)
     if parent_zone_to_location(
             old_parent,
             old_zone) in self.distobj_interests_location_to_do_id.keys():
         interested_distobjs = self.distobj_interests_location_to_do_id[
             parent_zone_to_location(old_parent, old_zone)]
         for distobj in interested_distobjs:
             self.distributed_objects[
                 distobj].interest_changing_location_leave(
                     sender, do_id, new_parent, new_zone, old_parent,
                     old_zone)
 def handle_STATESERVER_OBJECT_ENTER_AI_WITH_REQUIRED(self, dgi, sender, recipients):
     new_distobj = self.create_view_from_datagram(dgi, cls_postfix = 'AI')
     if new_distobj:
         view, do_id, parent_id, zone_id = new_distobj 
         if parent_zone_to_location(parent_id, zone_id) in self.distobj_interests_location_to_do_id.keys():
             interested_distobjs = self.distobj_interests_location_to_do_id[parent_zone_to_location(parent_id, zone_id)]
             for distobj in interested_distobjs:
                 self.distributed_objects[distobj].interest_distobj_ai_enter(view, do_id, parent_id, zone_id)
 def handle_STATESERVER_OBJECT_ENTER_LOCATION_WITH_REQUIRED(
         self, dgi, sender, recipients):
     new_distobj = self.create_view_from_datagram(dgi, cls_postfix='AE')
     if new_distobj:
         view, do_id, parent_id, zone_id = new_distobj
         if parent_zone_to_location(
                 parent_id,
                 zone_id) in self.distobj_interests_location_to_do_id.keys(
                 ):
             interested_distobjs = self.distobj_interests_location_to_do_id[
                 parent_zone_to_location(parent_id, zone_id)]
             for distobj in interested_distobjs:
                 self.distributed_objects[distobj].interest_distobj_enter(
                     view, do_id, parent_id, zone_id)
 def handle_STATESERVER_OBJECT_CHANGING_LOCATION(self, dgi, sender, recipients):
     print("handle_STATESERVER_OBJECT_CHANGING_LOCATION", sender, recipients)
     do_id = dgi.read_uint32()
     new_parent = dgi.read_uint32()
     new_zone = dgi.read_uint32()
     old_parent = dgi.read_uint32()
     old_zone = dgi.read_uint32()
     if parent_zone_to_location(new_parent, new_zone) in self.distobj_interests_location_to_do_id.keys():
         interested_distobjs = self.distobj_interests_location_to_do_id[parent_zone_to_location(new_parent, new_zone)]
         for distobj in interested_distobjs:
             self.distributed_objects[distobj].interest_changing_location_enter(sender, do_id, new_parent, new_zone, old_parent, old_zone)
     if parent_zone_to_location(old_parent, old_zone) in self.distobj_interests_location_to_do_id.keys():
         interested_distobjs = self.distobj_interests_location_to_do_id[parent_zone_to_location(old_parent, old_zone)]
         for distobj in interested_distobjs:
             self.distributed_objects[distobj].interest_changing_location_leave(sender, do_id, new_parent, new_zone, old_parent, old_zone)
 def add_ai_interest(self, distobj_id, zone_id, by_distobj=False):
     if by_distobj:
         print("Interest for %d in (%d, %d)" %
               (by_distobj, distobj_id, zone_id))
         if not (by_distobj
                 in self.distobj_interests_do_id_to_locations.keys()):
             self.distobj_interests_do_id_to_locations[by_distobj] = [
                 parent_zone_to_location(distobj_id, zone_id)
             ]
         else:
             self.distobj_interests_do_id_to_locations[by_distobj].append(
                 parent_zone_to_location(distobj_id, zone_id))
         if not (by_distobj
                 in self.distobj_interests_location_to_do_id.keys()):
             self.distobj_interests_location_to_do_id[
                 parent_zone_to_location(distobj_id,
                                         zone_id)] = [by_distobj]
         else:
             self.distobj_interests_location_to_do_id[
                 parent_zone_to_location(distobj_id,
                                         zone_id)].append(by_distobj)
     else:
         print("Interest for repo in (%d, %d)" % (distobj_id, zone_id))
         self.repo_interests.add(
             parent_zone_to_location(distobj_id, zone_id))
     self.send_CONTROL_ADD_CHANNEL(
         parent_zone_to_location(distobj_id, zone_id))
     # Request list of objects already existing in that zone for ENTER
     # FIXME: Can we do something with the context?
     print("repo: STATESERVER_OBJECT_GET_ZONE_OBJECTS(%d, %d)" %
           (distobj_id, zone_id))
     self.send_STATESERVER_OBJECT_GET_ZONE_OBJECTS(0, distobj_id, zone_id)
 def add_ai_interest(self, distobj_id, zone_id, by_distobj = False):
     if by_distobj:
         print("Interest for %d in (%d, %d)" % (by_distobj, distobj_id, zone_id))
         if not (by_distobj in self.distobj_interests_do_id_to_locations.keys()):
             self.distobj_interests_do_id_to_locations[by_distobj] = [parent_zone_to_location(distobj_id, zone_id)]
         else:
             self.distobj_interests_do_id_to_locations[by_distobj].append(parent_zone_to_location(distobj_id, zone_id))
         if not (by_distobj in self.distobj_interests_location_to_do_id.keys()):
             self.distobj_interests_location_to_do_id[parent_zone_to_location(distobj_id, zone_id)] = [by_distobj]
         else:
             self.distobj_interests_location_to_do_id[parent_zone_to_location(distobj_id, zone_id)].append(by_distobj)
     else:
         print("Interest for repo in (%d, %d)" % (distobj_id, zone_id))
         self.repo_interests.add(parent_zone_to_location(distobj_id, zone_id))
     self.send_CONTROL_ADD_CHANNEL(parent_zone_to_location(distobj_id, zone_id))
     # Request list of objects already existing in that zone for ENTER 
     # FIXME: Can we do something with the context?
     print("repo: STATESERVER_OBJECT_GET_ZONE_OBJECTS(%d, %d)" % (distobj_id, zone_id))
     self.send_STATESERVER_OBJECT_GET_ZONE_OBJECTS(0, distobj_id, zone_id)