Handle subscribe/unsubscribe http requests
963923
function(credentials, callback_url, api_endpoint) {
  this._credentials = credentials;
  this._callback    = callback_url;
  this._endpoint    = api_endpoint;
  this._fields      = "feed";
}
33057
def subscribe(self, feedUrl):
        
        response = self.httpPost(
            ReaderUrl.SUBSCRIPTION_EDIT_URL,
            {'ac':'subscribe', 's': feedUrl})
        # FIXME - need better return API
        if response and 'OK' in response:
            return True
        else:
            return False
1164760
def on_connect(self, connection):
        ""
        # NOTE: for python3, we can't pass bytestrings as keyword arguments
        # so we need to decode channel/pattern names back to unicode strings
        # before passing them to [p]subscribe.
        self.pending_unsubscribe_channels.clear()
        self.pending_unsubscribe_patterns.clear()
        if self.channels:
            channels = {}
            for k, v in iteritems(self.channels):
                channels[self.encoder.decode(k, force=True)] = v
            self.subscribe(**channels)
        if self.patterns:
            patterns = {}
            for k, v in iteritems(self.patterns):
                patterns[self.encoder.decode(k, force=True)] = v
            self.psubscribe(**patterns)
810476
def unsubscribe(self, callback_id):
        
        request = self.get_active_subscription(callback_id)
        request['mode'] = 'unsubscribe'
        self.subscribe_impl(callback_id, **request)
211171
function execute(req, res) {
  this.state.pubsub.subscribe(req.conn, req.args);
}
411651
public void subscriptionRequestReceived(SubscriptionRequest sr) throws SubscriptionException {

        LOG.info("Subscriber -> (Hub), new subscription request received.", sr.getCallback());

        try {

            verifySubscriberRequestedSubscription(sr);

            if ("subscribe".equals(sr.getMode())) {
                LOG.info("Adding callback {} to the topic {}", sr.getCallback(), sr.getTopic());
                addCallbackToTopic(sr.getCallback(), sr.getTopic());
            } else if ("unsubscribe".equals(sr.getMode())) {
                LOG.info("Removing callback {} from the topic {}", sr.getCallback(), sr.getTopic());
                removeCallbackToTopic(sr.getCallback(), sr.getTopic());
            }

        } catch (Exception e) {
            throw new SubscriptionException(e);
        }

    }
875617
function(client, subscriptions, channel, callback, done_callback) {
    if (subscriptions[channel]===undefined)
        return;
    subscriptions[channel].splice(subscriptions[channel].indexOf(callback), 1);
    if (subscriptions[channel].length===0) {
        delete subscriptions[channel];
        client.unsubscribe(channel, function() {
            // If there is a done_callback defined, execute it
            if (done_callback!==undefined) done_callback();
        });
    }
}
37940
function unsubscribe(message) {
		reply(proto.writeUnsubscribe(message.id));
		subscritions[message.itemName] = undefined;
		dequeueSubUnsubRequest(message.itemName);
		handleLateSubUnsubRequests(message.itemName);
		fireFirstSubUnsubEvent(message.itemName);
	}
720792
def unsubscribe(self, future):
        
        assert future not in self._pending_unsubscribes, \
            "%r has already been unsubscribed from" % \
            self._pending_unsubscribes[future]
        subscribe = self._requests[future]
        self._pending_unsubscribes[future] = subscribe
        # Clear out the subscription
        self._subscriptions.pop(subscribe.id)
        request = Unsubscribe(subscribe.id)
        request.set_callback(self._q.put)
        try:
            controller = self.get_controller(subscribe.path[0])
        except ValueError:
            # Controller has already gone, probably during tearDown
            pass
        else:
            self.handle_request(controller, request)
1374137
def unsubscribe(self, socket_id, channel):
        """"""
        con = self._get_connection(socket_id, create=False)
        if con is not None:
            con.subscriptions.discard(channel)
        try:
            self.subscriptions[channel].discard(socket_id)
        except KeyError:
            pass
728923
function subscribe() {
    // starts to receive values after device regsiters
    connect.subscribe.resourceValues({ resourcePaths: ["/3200/0/5501"] })
        .addListener((res) => logData(res, "OnRegistration"))
        .addLocalFilter(res => res.payload >= 20);

    // starts to reveive values immediatley
    connect.subscribe.resourceValues({ resourcePaths: ["/3200/0/5501"] }, "OnValueUpdate")
        .addListener((res) => logData(res, "OnValueUpdate"));
}
837101
function execute(req, res) {
  this.state.pubsub.psubscribe(req.conn, req.args);
}
968373
function subscribe() {
    console.log(' > ', 'init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123']);
    rpcClient.methodCall('init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123'], function (err, res) {
        console.log(err, res);
    });
}
1018229
function(params, callback) {
        if (!client) {
          fireEvent("error", {
            errorCode: 999,
            errorMessage: "ActiveMQ Client is not ready or has not been initialized!"
          });
        }

        var subscribeHeaders = {
          "destination": params.destination,
          "ack": params.ack
        };

        client.subscribe(subscribeHeaders, function(error, message) {
          if (error) {
            fireEvent("error", {
              errorCode: 999,
              errorMessage: "ActiveMQ Subscription Error!"
            });
            return;
          }

          message.readString("utf-8", function(error, body) {
            if (error) {
              fireEvent("error", {
                errorCode: 999,
                errorMessage: "ActiveMQ Read Message Error!"
              });
              return;
            }

            callback && callback(body);

            client.ack(message);
          });
        });
      }
325641
def unsubscribe_url(self):
        """"""
        server_relative = ('%s?s=%s' % (reverse('tidings.unsubscribe',
                                                args=[self.pk]),
                                        self.secret))
        return 'https://%s%s' % (Site.objects.get_current().domain,
                                 server_relative)
917859
def subscribe(self, callback_url, timeout=None):
        
        url = urljoin(self._url_base, self._event_sub_url)
        headers = dict(
            HOST=urlparse(url).netloc,
            CALLBACK='<%s>' % callback_url,
            NT='upnp:event'
        )
        if timeout is not None:
            headers['TIMEOUT'] = 'Second-%s' % timeout
        resp = requests.request('SUBSCRIBE', url, headers=headers, auth=self.device.http_auth)
        resp.raise_for_status()
        return Service.validate_subscription_response(resp)
67373
def _execute(self, sender, event_args):
        '''
        
        '''
        with self._lock:
            while not self._messages.empty():
                msg, args, kwargs = self._messages.get(False)
                for subscriber in self._subscribers[msg]:
                    try:
                        subscriber(*args, **kwargs)
                    except weakref.ReferenceError:
                        # Reference to handler is lost and it is OK to silence it
                        pass