flow for subscription.
3686
public void onInfiniteGasButtonClicked(View arg0) {
        if (setupDone == null) {
            complain("Billing Setup is not completed yet");
            return;
        }

        if (!setupDone) {
            complain("Billing Setup failed");
            return;
        }

        if (!mHelper.subscriptionsSupported()) {
            complain("Subscriptions not supported on your device yet. Sorry!");
            return;
        }

        /* TODO: for security, generate your payload here for verification. See the comments on
         *        verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
         *        an empty string, but on a production app you should carefully generate this. */
        String payload = "";

        setWaitScreen(true);
        Log.d(TAG, "Launching purchase flow for infinite gas subscription.");
        mHelper.launchPurchaseFlow(this,
                InAppConfig.SKU_INFINITE_GAS, IabHelper.ITEM_TYPE_SUBS,
                RC_REQUEST, mPurchaseFinishedListener, payload);
    }
925887
def manage_subscription():
    """"""
    subscription = processor.create_parameter_subscription([
        '/YSS/SIMULATOR/BatteryVoltage1'
    ])

    sleep(5)

    print('Adding extra items to the existing subscription...')
    subscription.add([
        '/YSS/SIMULATOR/Alpha',
        '/YSS/SIMULATOR/BatteryVoltage2',
        'MDB:OPS Name/SIMULATOR_PrimBusVoltage1',
    ])

    sleep(5)

    print('Shrinking subscription...')
    subscription.remove('/YSS/SIMULATOR/Alpha')

    print('Cancelling the subscription...')
    subscription.cancel()

    print('Last values from cache:')
    print(subscription.get_value('/YSS/SIMULATOR/BatteryVoltage1'))
    print(subscription.get_value('/YSS/SIMULATOR/BatteryVoltage2'))
    print(subscription.get_value('/YSS/SIMULATOR/Alpha'))
    print(subscription.get_value('MDB:OPS Name/SIMULATOR_PrimBusVoltage1'))
884930
def auto_subscribe(self, app_manager):
        """"""
        for handler in app_manager.handler_classes:
            app_manager.subscribe(handler.channel(), self)
236617
function (subscription, cb) {

		Subscription.findOrCreate(subscription.id, subscription)
	    .exec(function (err, foundSubscription){
	      if (err) return cb(err);
	      if (foundSubscription.lastStripeEvent > subscription.lastStripeEvent) return cb(null, foundSubscription);
	      if (foundSubscription.lastStripeEvent == subscription.lastStripeEvent) return Subscription.afterStripeCustomerSubscriptionUpdated(foundSubscription, function(err, subscription){ return cb(err, subscription)});
	      Subscription.update(foundSubscription.id, subscription)
	      .exec(function(err, updatedSubscriptions){
	      	if (err) return cb(err);
	      	if(!updatedSubscriptions) return cb(null, null);
	      	Subscription.afterStripeCustomerSubscriptionUpdated(updatedSubscriptions[0], function(err, subscription){
	      		cb(err, subscription);
	      	});
	      });
	    });
	}
788549
def sync_subscriber(subscriber):
	""""""
	customer, _created = Customer.get_or_create(subscriber=subscriber)
	try:
		customer.sync_from_stripe_data(customer.api_retrieve())
		customer._sync_subscriptions()
		customer._sync_invoices()
		customer._sync_cards()
		customer._sync_charges()
	except InvalidRequestError as e:
		print("ERROR: " + str(e))
	return customer
360179
def accept_subscription(&blk)
      pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribed')
      connection.send_stanza pres, &blk
    end
740304
def fetch(self, subscription_id, data={}, **kwargs):
        "
        return super(Subscription, self).fetch(subscription_id, data, **kwargs)
355074
def subscribe(self, client):
        """"""
        self.clients.append(client)
        log("Subscribed client {} to channel {}".format(client, self.name))
40303
def endSubscription(self, subscriber):
        
        self._reqId2Contract.pop(subscriber.reqId, None)
        self.reqId2Subscriber.pop(subscriber.reqId, None)
1087866
def subscribe_to(channel, opts = {})
      js_tag = opts.delete(:include_js_tag){ true }
      subscription = Danthes.subscription(channel: channel)
      content = raw("if (typeof Danthes != 'undefined') { Danthes.sign(#{subscription.to_json}) }")
      js_tag ? content_tag('script', content, type: 'text/javascript') : content
    end
485597
function subscribeNode (client, subscriptions, channel, callback, done_callback) {
    if (subscriptions[channel]===undefined) {
        subscriptions[channel] = [callback];
        client.subscribe(channel, {qos: 0}, function() {
            // If there is a done_callback defined, execute it
            if (done_callback!==undefined) done_callback();
        });
    } else {
        subscriptions[channel].push(callback);
    }
}
857101
function(service, credentials, accounts, keywords) {
  Stream.call(this, service, credentials, accounts, keywords);
  
  // Initialize FBGraph
  fbgraph.setAccessToken(credentials.access_token);
  
  // Set api endpoint URL for subscriber
  this.api_endpoint = 'https://graph.facebook.com/'+ credentials.app_id +'/subscriptions/';
  
  // Initialize subscriber object
  this.subscriber = new Subscriber(credentials, this.callback_url(), this.api_endpoint);
  
  // Initialize responder
  this.responder = new Responder();
  
  // Start listening for incoming
  process.nextTick(function() {
      this.delegateResponder();
    }.bind(this));
  
}
459710
def create_subscription(self, subscription):
        
        if subscription.subscription_id is not None:
            self._validate_uuid(subscription.subscription_id)

        if subscription.endpoint is not None:
            if subscription.endpoint.subscriber_id is not None:
                self._validate_subscriber_id(
                    subscription.endpoint.subscriber_id)

            if subscription.endpoint.endpoint_id is not None:
                self._validate_uuid(subscription.endpoint.endpoint_id)

        if subscription.channel is not None:
            self._validate_uuid(subscription.channel.channel_id)

        url = "/notification/v1/subscription"
        response = NWS_DAO().postURL(url, self._write_headers(),
                                     self._json_body(subscription.json_data()))

        if response.status != 201:
            raise DataFailureException(url, response.status, response.data)

        return response.status
150271
def save(self, *args, **kwargs):
        """"""
        method_kwargs = self._get_method_kwargs()
        try:
            subscription = Subscription.objects.get(**method_kwargs)
        except Subscription.DoesNotExist:
            subscription = Subscription.objects.create(**method_kwargs)
        return subscription
793954
def subscribe(
            self,
            subject="",
            queue="",
            cb=None,
            future=None,
            max_msgs=0,
            is_async=False,
            pending_msgs_limit=DEFAULT_SUB_PENDING_MSGS_LIMIT,
            pending_bytes_limit=DEFAULT_SUB_PENDING_BYTES_LIMIT,
    ):
        
        if self.is_closed:
            raise ErrConnectionClosed

        if self.is_draining:
            raise ErrConnectionDraining

        self._ssid += 1
        sid = self._ssid
        sub = Subscription(
            subject=subject,
            queue=queue,
            cb=cb,
            future=future,
            max_msgs=max_msgs,
            is_async=is_async,
            sid=sid,
        )
        self._subs[sid] = sub

        if cb is not None:
            sub.pending_msgs_limit = pending_msgs_limit
            sub.pending_bytes_limit = pending_bytes_limit
            sub.pending_queue = tornado.queues.Queue(
                maxsize=pending_msgs_limit)

            @tornado.gen.coroutine
            def wait_for_msgs():
                while True:
                    sub = wait_for_msgs.sub
                    err_cb = wait_for_msgs.err_cb

                    try:
                        sub = wait_for_msgs.sub
                        if sub.closed:
                            break

                        msg = yield sub.pending_queue.get()
                        if msg is None:
                            break

                        sub.received += 1
                        sub.pending_size -= len(msg.data)
                        if sub.max_msgs > 0 and sub.received >= sub.max_msgs:
                            # If we have hit the max for delivered msgs, remove sub.
                            self._subs.pop(sub.sid, None)
                            self._remove_subscription(sub)

                        # Invoke depending of type of handler.
                        if sub.is_async:
                            # NOTE: Deprecate this usage in a next release,
                            # the handler implementation ought to decide
                            # the concurrency level at which the messages
                            # should be processed.
                            self._loop.spawn_callback(sub.cb, msg)
                        else:
                            yield sub.cb(msg)
                    except Exception as e:
                        # All errors from calling an async subscriber
                        # handler are async errors.
                        if err_cb is not None:
                            yield err_cb(e)

            # Bind the subscription and error cb if present
            wait_for_msgs.sub = sub
            wait_for_msgs.err_cb = self._error_cb
            self._loop.spawn_callback(wait_for_msgs)

        elif future is not None:
            # Used to handle the single response from a request
            # based on auto unsubscribe.
            sub.future = future

        # Send SUB command...
        sub_cmd = b''.join([
            SUB_OP, _SPC_,
            sub.subject.encode(), _SPC_,
            sub.queue.encode(), _SPC_, ("%d" % sid).encode(), _CRLF_
        ])
        yield self.send_command(sub_cmd)
        yield self._flush_pending()
        raise tornado.gen.Return(sid)
370738
def subscriptions(self):
        """"""
        if not hasattr(self, '_subscriptions'):
            subscriptions_resource = self.resource.subscriptions
            self._subscriptions = Subscriptions(
                subscriptions_resource, self.client)
        return self._subscriptions
550606
function (channel, subscription, context) {
      Backbone.Mediator.subscribe(channel, subscription, context, true);
    }