- pub fn add_packet_listener<P: PacketAdapter + 'static>(&self, listener: P) -> usize {
- let mut listeners = self.listeners.write().unwrap();
- let id = listeners.next;
- listeners.next += 1;
- listeners.packet.insert(id, Arc::new(listener));
+ pub fn add_packet_adapter<P: PacketAdapter + 'static>(&self, adapter: P) -> usize {
+ let adapter = Arc::new(adapter);
+ let mut adapters = self.adapters.write().unwrap();
+ let id = adapters.next;
+ adapters.next += 1;
+ adapters.packet.insert(id, adapter.clone());
+ drop(adapters);
+ adapter.adapter_registered(id, self.tx());