def on_inter_message(self, channel, method, header, body): """ Process an "inter" message. """ sess = meta.Session() channel.basic_ack(delivery_tag=method.delivery_tag) prefixparts = method.routing_key.split(".") packet = deserializePacket(body) packet._origin = ORIGIN_INTER if prefixparts[1] == "global": for user in sess.query(User): packet.dispatch(self.core, FakeSession(user.id)) return ident = uuid.UUID(hex=prefixparts[2]) if prefixparts[1] == "User": user = sess.query(User).get(ident) packet.dispatch(self.core, FakeSession(user.id)) elif prefixparts[1] == "Tile": for user in sess.query(User).filter(User.location_id == ident): packet.dispatch(self.core, FakeSession(user.id)) elif prefixparts[1] == "Group": for user in sess.query(User).filter(User.group_id == ident): packet.dispatch(self.core, FakeSession(user.id)) elif prefixparts[1] == "Realm": for user in sess.query(User).filter(User.location_id == Tile.id).filter(Tile.chunk_id == Chunk.id).filter(Chunk.realm_id == Realm.id).filter(Realm.id == ident): packet.dispatch(self.core, FakeSession(user.id))
def post(self, *args, **kwargs): self.token = uuid.UUID(hex=self.get_argument("s")) session = meta.Session().query(Session).get(self.token) payload = self.get_argument("p") try: packet = deserializePacket(payload) packet._origin = ORIGIN_EX except ValueError: session.sendEx(self.application.bus, PacketError(msg="bad packet payload")) else: packet.dispatch(self.application, session) self.finish()