项目作者: ScaleDrone

项目描述 :
Ruby library for Scaledrone Realtime Messaging Service
高级语言: Ruby
项目地址: git://github.com/ScaleDrone/scaledrone-ruby.git
创建时间: 2015-10-31T17:21:19Z
项目社区:https://github.com/ScaleDrone/scaledrone-ruby

开源协议:

下载


Scaledrone Ruby API

Official ScaleDrone Ruby pushing library. This is a wrapper around the REST API.

Installation

Add this line to your application’s Gemfile:

  1. gem 'scaledrone'

And then execute:

  1. bundle install

Or install it directly:

  1. gem install 'scaledrone'

Usage

Create a new instance of ScaleDrone passing it the channelId and secretKey that you can find from the channel’s page

  1. require 'scaledrone'
  2. sd = ScaleDrone.new({
  3. channel_id: 'G3TYvCzoXtrIuEtQ',
  4. secret_key: 'M7Oc1DY2FgkCaUh4aQFC3TRV1R3RThPd'
  5. })

Publishing a message

Please notice that in 1.0.0 the function header changed, when upgrading from 0.X.X you need to switch message and room order.

  1. room = 'notifications'
  2. message = {foo: 'bar'}
  3. response = sd.publish(message, room)

Publishing the same message to multiple rooms

  1. rooms = ['notifications', 'lounge']
  2. message = {foo: 'bar'}
  3. response = sd.publish(message, *rooms)

Channel stats

  1. response = sd.channel_stats()

Connected users list

  1. response = sd.users_list()