Subscribe to a channel

@param channel
333792
function(channel, subscription, context, once) {
      if (!channels[channel]) channels[channel] = [];
      channels[channel].push({fn: subscription, context: context || this, once: once});
    }
969181
@Override
    public void subscribe(final Subscriber<? super T> s) {

       transformerStream().forEach(v->v.subscribe(s));

    }
1203230
def join(self, channel):
        
        
        if channel not in self.channels:
            channel.users.add(self.nick)
            self.channels.append(channel)
1190033
@Override @CallerSideMethod
    public void subscribe(Subscriber<? super OUT> subscriber) {
        if ( isRemote() ) {
            synchronized (this) { // subscribe/unsubscribe won't be contended
                if ( _callerSideSubscribers == null ) {
                    _callerSideSubscribers = new ArrayList();
                }
                _callerSideSubscribers.add(subscriber);
            }
        }
        if ( subscriber == null )
        {
            subscriber.onError( new IllegalArgumentException("cannot subscibe null") );
            return;
        }
        _subscribe((res, err) -> {
            if (isError(err)) {
                subscriber.onError((Throwable) err);
            } else if (isComplete(err)) {
                subscriber.onComplete();
            } else {
                subscriber.onNext((OUT) res);
            }
        }).then(subs -> {
            Log.Info(this, "stream subscribe acknowledged");
            subscriber.onSubscribe(subs);
        });
    }
1183073
public void addChannel(WebSocketChannel channel) {
        Objects.requireNonNull(channel, Required.CHANNEL.toString());

        final String url = RequestUtils.getWebSocketURL(channel);
        Set<WebSocketChannel> channels = getChannels(url);
        if (channels == null) {
            channels = new HashSet<>();
            channels.add(channel);
        } else {
            channels.add(channel);
        }
        setChannels(url, channels);
    }
75448
synchronized void setChannelFactory(ChannelFactory factory) throws ChannelFactoryException {
        if (factory != null && cf != null) {
            throw new ChannelFactoryException("ChannelFactory already exists");
        }
        this.cf = factory;
    }
156856
public void setMessageChannel(MessageChannel channel) {
        if (_mchannel == null) {
            _mchannel = channel;
        } else {
            _mchannel = new CompoundChannel(_mchannel, channel);
        }
    }
927613
void reSubscribeByName(EventChannelStruct event_channel_struct, String name) {
        Enumeration callback_structs = event_callback_map.elements();
        while (callback_structs.hasMoreElements()) {
            EventCallBackStruct callback_struct = (EventCallBackStruct) callback_structs.nextElement();
            if (callback_struct.channel_name.equals(name)) {
                reSubscribe(event_channel_struct, callback_struct);
            }
        }
    }
22060
public function subscribe()
    {
        if ($this->type == "subscription") {
            throw new Exceptions\ChannelException("Already subscribed to this channel.");
        }

        if (!empty($this->myChannel)) {
            throw new Exceptions\ChannelException("Cannot subscribe to own channel.");
        }

        try {
            return new Channel(
                Connection::sendCurlRequest(Connection::URL_SUBSCRIPTIONS, 'POST', ['channel_tag' => $this->channelTag],
                    true, $this->apiKey), $this->apiKey
            );
        } catch (Exceptions\ConnectionException $e) {
            if ($e->getCode() === 400) {
                throw new Exceptions\NotFoundException("Channel does not exist.");
            } else {
                throw $e;
            }
        }
    }
1334537
public void setChannels(java.util.Collection<String> channels) {
        if (channels == null) {
            this.channels = null;
            return;
        }

        this.channels = new java.util.ArrayList<String>(channels);
    }
94128
@Override
	public Promise subscribe(String channel) {
		Promise promise = new Promise();
		if (client != null) {
			try {
				client.subscribe(new Subscription[] { new Subscription(channel, qos) });
				subscriptions.put(channel, promise);
			} catch (Exception cause) {
				promise.complete(cause);
			}
		} else {
			promise.complete(new Throwable("Not connected!"));
		}
		return promise;
	}
1225804
@Override
	public Promise subscribe(String channel) {
		try {

			// Create topic
			ProjectTopicName topicName = ProjectTopicName.of(projectID, channel);
			Topic topic = null;
			try {
				topic = topicAdmin.getTopic(topicName);
			} catch (NotFoundException notFound) {
			}
			if (topic == null) {
				topic = topicAdmin.createTopic(topicName);
				logger.info("Topic \"" + topic.getName() + "\" created successfully.");
			}

			// Create subscription
			String nodeSubscription;
			if (channel.endsWith('.' + nodeID)) {
				nodeSubscription = channel;
			} else {
				nodeSubscription = channel + '-' + nodeID;
			}
			ProjectSubscriptionName subscriptionName = ProjectSubscriptionName.of(projectID, nodeSubscription);
			Subscription subscription = null;
			try {
				subscription = subscriptionAdmin.getSubscription(subscriptionName);
			} catch (NotFoundException notFound) {
			}
			if (subscription == null) {
				subscription = subscriptionAdmin.createSubscription(subscriptionName, topicName,
						PushConfig.getDefaultInstance(), ackDeadlineSeconds);
				logger.info("Subscription \"" + subscription.getName() + "\" created successfully.");
			}

			// Create subscriber
			synchronized (subscribers) {
				if (!subscribers.containsKey(nodeSubscription)) {
					Subscriber.Builder builder = Subscriber.newBuilder(subscriptionName, (message, consumer) -> {

						// Message received
						try {

							// We are running in a netty executor's pool,
							// do not create new task.
							processReceivedMessage(channel, message.getData().toByteArray());
						} finally {
							consumer.ack();
						}

					});
					if (channelProvider != null) {
						builder.setChannelProvider(channelProvider);
					}
					if (credentialsProvider != null) {
						builder.setCredentialsProvider(credentialsProvider);
					}
					if (executorProvider != null) {
						builder.setExecutorProvider(executorProvider);
						builder.setSystemExecutorProvider(executorProvider);
					} else {
						builder.setExecutorProvider(defaultExecutorProvider);
						builder.setSystemExecutorProvider(defaultExecutorProvider);
					}
					if (headerProvider != null) {
						builder.setHeaderProvider(headerProvider);
					}
					if (maxAckExtensionPeriod != null) {
						builder.setMaxAckExtensionPeriod(maxAckExtensionPeriod);
					}
					if (parallelPullCount > 0) {
						builder.setParallelPullCount(parallelPullCount);
					}
					if (flowControlSettings != null) {
						builder.setFlowControlSettings(flowControlSettings);
					}
					Subscriber subscriber = builder.build();
					subscriber.startAsync();
					subscribers.put(nodeSubscription, subscriber);
					logger.info(
							"Subscriber created for subscription \"" + subscriber.getSubscriptionNameString() + "\".");
				}
			}

		} catch (Exception cause) {
			return Promise.reject(cause);
		}
		return Promise.resolve();
	}
942479
public void setChannels(java.util.Collection<Channel> channels) {
        if (channels == null) {
            this.channels = null;
            return;
        }

        this.channels = new java.util.ArrayList<Channel>(channels);
    }
836661
function subscribe(conn, channels) {
  return this.doSubscribe(
    PUBSUB.SUBSCRIBE,
    PUBSUB.CHANNELS,
    this._channels, conn, channels);
}
422706
function (h, c) {
        var len = c.length;
        var i = len;
        var f = function () {
            if (!(--i)) h();
        };
        for (var j = 0; j < len; j++) {
            if (c[j].state === 0) {
                throw Error('Can only use join with sticky channels.');
            }
            c[j].subscribe(f);
        }
        if (!len) h();
    }
759256
@Override
	public Promise subscribe(String channel) {
		poller.subscribe(channel);
		return Promise.resolve();
	}
204122
function(channel) {
      if (!channels[channel]) return;

      var args = [].slice.call(arguments, 1),
          subscription;

      for (var i = 0; i < channels[channel].length; i++) {
        subscription = channels[channel][i];
        subscription.fn.apply(subscription.context, args);
        if (subscription.once) {
          Backbone.Mediator.unsubscribe(channel, subscription.fn, subscription.context);
          i--;
        }
      }
    }