Skip to content

Repository files navigation

deepstream-ruby

deepstream.io ruby client deepstream version >5 needed

Gem VersionGem License

Installation

gem install deepstream

Usage

Client initialization

ds=Deepstream::Client.new('localhost')# ords=Deepstream::Client.new('ws://localhost:6020')# ords=Deepstream::Client.new('ws://localhost:6020/deepstream-v3',ack_timeout: nil,# ACK timeout; if nil, then the client never checks ACK timeout errorscredentials: {username: 'John',password: 'Doe'},# credentials used to authorise the clientheartbeat_interval: nil# when two server heartbeats are missed the client considers the connection to be lostemit_timeout: 0,# if 0, then events that failed to be emitted are thrown away# if nil, then events are stored in a buffer, waiting for reconnection# if another number, then events are stored in a buffer and sent if the client reconnects in emit_timeout secondsverbose: false,# show verbose information about connection, incoming and outgoing messages etc.debug: false,# use for testing only; if true, any exception will terminate the clientin_thread: true# if true, putting client in separated thread)# log in to the serverds.login# you can use new credentials toods.login(username: 'John',password: 'betterDoe')# check if the websocket connection is openedds.connected?# check if the client is logged inds.logged_in?

Events

# emit an eventds.emit('my_event')# ords.emit('my_event',foo: 'bar',bar: 'foo')# ords.emit('my_event',foo: 'bar',bar: 'foo',timeout: 10)# emit with a custom timeout# subscribe to eventsds.on('my_event'){ |data| putsdata}

Records

# get a record# list is an optional argument; when given, the client adds the record to a list with given namefoo=ds.get('foo',list: 'bar')# orfoo=ds.get_record('foo',list: 'bar')# Update a recordfoo.set('bar','bar')# update 'bar' attribute# orfoo.bar='bar'# or set the whole record data at oncefoo.set(bar: 'bar',baz: 'baz')

Lists

# get a listfoo=ds.get_list('foo')# add to the listfoo.add('bar')# Remove from listfoo.remove('foo')# show record names in the listfoo.data# orfoo.keys# get records from the listfoo.all# callbacksfoo.on(:added){ |record| }foo.on(:removed){ |record| }

Development

git submodule update --init --recursive

To Do

Adjust tests, to work with new version (without celluloid)

About

deepstream.io ruby client

Topics

Resources

Stars

9 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages