How to create channel programmatically on socketcluster? -


i'm considering using socketcluster build realtime app. docs clear not find way create channel on demand programmatically.

my need is: user, call rest api create channel , running on server.

for example, calling client side: post https://<myserver>/api/channels json body { "channel": "mychannel} create mychannel channel on server , client side code able subscribe directly (after having received server response):

 var mychannel = socket.subscribe('mychannel');  mychannel.publish('mychannel', 'i here !');  mychannel.watch(function (data) {      console.log('received data mychannel:', data);  }); 

i suppose newly created channel use authorization middleware middlewares defined @ server level (wsserver.addmiddleware(wsserver.middleware_subscribe, ...)

thanks lot help,

pierre

with socketcluster, channels created , destroyed automatically don't need manage lifecycle. channel created on end if there @ least 1 client subscribed (based on channel name) , automatically destroyed once of clients have disconnected or unsubscribed it. sc accounts failure cases - e.g. if internet connections unexpectedly lost.

sc designed efficient @ creating , destroying lots of unique channels on fly. can have hundreds of unique channels per user (so possibly many thousands or millions of unique channels in total). channels don't consume cpu @ if they're idle , each channel has tiny memory footprint.

channels in sc not message queues (unlike offered rabbitmq, nsq, kafka, stomp...); sc not store messages on persistent queue (though can extend sc own persistence logic).


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -