def send_CLIENT_REMOVE_INTEREST(self, interest_id, context_id): # FIXME: Should something be done about callbacks here? dg = Datagram() dg.add_uint16(clientmsg.CLIENT_REMOVE_INTEREST) dg.add_uint32(context_id) dg.add_uint16(interest_id) self.send_datagram(dg)
def send_CLIENT_ADD_INTEREST_MULTIPLE(self, parent_id, zone_ids, interest_id=0, callback=False, callback_args=[], callback_kwargs={}): zone_count = len(zone_ids) # FIXME: interest_id (uint16), parent_id (uint32), zone_id (uint32) should # be asserted. if not (interest_id in self.interest_counters.keys()): self.interest_counters[interest_id] = -1 # FIXME: This needs to be protected against uint32 roll-overs. I'll probably # need to have a set of freed context_ids. But what if there are no more # usable context_ids? Raise an Exception? self.interest_counters[ interest_id] = self.interest_counters[interest_id] + 1 context_id = self.interest_counters[interest_id] dg = Datagram() dg.add_uint16(clientmsg.CLIENT_ADD_INTEREST_MULTIPLE) dg.add_uint32(context_id) dg.add_uint16(interest_id) dg.add_uint32(parent_id) dg.add_uint16(zone_count) for zone_id in zone_ids: dg.add_uint32(zone_id) self.send_datagram(dg) if callback != False: self.interest_callback_map[(interest_id, context_id)] = (callback, callback_args, callback_kwargs) return context_id
def send_CLIENT_ADD_INTEREST_MULTIPLE(self, parent_id, zone_ids, interest_id = 0, callback = False, callback_args = [], callback_kwargs = {}): zone_count = len(zone_ids) # FIXME: interest_id (uint16), parent_id (uint32), zone_id (uint32) should # be asserted. if not (interest_id in self.interest_counters.keys()): self.interest_counters[interest_id] = -1 # FIXME: This needs to be protected against uint32 roll-overs. I'll probably # need to have a set of freed context_ids. But what if there are no more # usable context_ids? Raise an Exception? self.interest_counters[interest_id] = self.interest_counters[interest_id] + 1 context_id = self.interest_counters[interest_id] dg = Datagram() dg.add_uint16(clientmsg.CLIENT_ADD_INTEREST_MULTIPLE) dg.add_uint32(context_id) dg.add_uint16(interest_id) dg.add_uint32(parent_id) dg.add_uint16(zone_count) for zone_id in zone_ids: dg.add_uint32(zone_id) self.send_datagram(dg) if callback != False: self.interest_callback_map[(interest_id, context_id)] = (callback, callback_args, callback_kwargs) return context_id
def send_CLIENT_HELLO(self): dg = Datagram() dg.add_uint16(clientmsg.CLIENT_HELLO) dg.add_uint32(traits.legacy_hash(self.mod)) dg.add_string(self.version_string) self.send_datagram(dg)