Class: RubyDdp::Client

Inherits:
Faye::WebSocket::Client
  • Object
show all
Defined in:
lib/ruby-ddp-client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 3000, path = 'websocket') ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
# File 'lib/ruby-ddp-client.rb', line 10

def initialize(host, port = 3000, path = 'websocket')
  super("http://#{host}:#{port}/#{path}")
  self.init_event_handlers()
  
  @_callbacks = {}
  @_next_id = 0
  @collections = {}
end

Instance Attribute Details

#collectionsObject

Returns the value of attribute collections.



8
9
10
# File 'lib/ruby-ddp-client.rb', line 8

def collections
  @collections
end

#onconnectObject

Returns the value of attribute onconnect.



7
8
9
# File 'lib/ruby-ddp-client.rb', line 7

def onconnect
  @onconnect
end

Instance Method Details

#call(method, params = [], &blk) ⇒ Object



23
24
25
26
27
# File 'lib/ruby-ddp-client.rb', line 23

def call(method, params = [], &blk)
  id = self.next_id()
  self.dosend(:msg => 'method', :id => id, :method => method, :params => params)
  @_callbacks[id] = blk
end

#connectObject



19
20
21
# File 'lib/ruby-ddp-client.rb', line 19

def connect
  dosend(:msg => :connect)
end

#subscribe(name, params, &blk) ⇒ Object



29
30
31
32
33
# File 'lib/ruby-ddp-client.rb', line 29

def subscribe(name, params, &blk)
  id = self.next_id()
  self.dosend(:msg => 'sub', :id => id, :name => name, :params => params)
  @_callbacks[id] = blk
end