示例#1
0
            topic, subscribers = self._subscription_to_sessions[
                unsubscribe.subscription]

            subscribers.discard(session)

            if not subscribers:
                del self._subscription_to_sessions[unsubscribe.subscription]

            _, subscribers = self._topic_to_sessions[topic]

            subscribers.discard(session)

            if not subscribers:
                del self._topic_to_sessions[topic]

            self._session_to_subscriptions[session].discard(
                unsubscribe.subscription)

            reply = message.Unsubscribed(unsubscribe.request)

        else:
            reply = message.Error(message.Unsubscribe.MESSAGE_TYPE,
                                  unsubscribe.request,
                                  ApplicationError.NO_SUCH_SUBSCRIPTION)

        session._transport.send(reply)


IBroker.register(Broker)
示例#2
0
      #assert(session in self._session_to_subscriptions)

      if unsubscribe.subscription in self._subscription_to_sessions:

         topic, subscribers = self._subscription_to_sessions[unsubscribe.subscription]

         subscribers.discard(session)

         if not subscribers:
            del self._subscription_to_sessions[unsubscribe.subscription]

         _, subscribers = self._topic_to_sessions[topic]

         subscribers.discard(session)

         if not subscribers:
            del self._topic_to_sessions[topic]

         self._session_to_subscriptions[session].discard(unsubscribe.subscription)

         reply = message.Unsubscribed(unsubscribe.request)

      else:
         reply = message.Error(message.Unsubscribe.MESSAGE_TYPE, unsubscribe.request, ApplicationError.NO_SUCH_SUBSCRIPTION)

      session._transport.send(reply)



IBroker.register(Broker)