Class: Peatio::MQ::Events::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/peatio/mq/events.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket, streams = {}) ⇒ Client

Returns a new instance of Client.


38
39
40
41
42
43
44
45
46
# File 'lib/peatio/mq/events.rb', line 38

def initialize(socket, streams = {})
  @socket = socket
  @streams = streams

  @user = ""
  @authorized = false

  @@all << self
end

Instance Attribute Details

#authorizedObject

Returns the value of attribute authorized


22
23
24
# File 'lib/peatio/mq/events.rb', line 22

def authorized
  @authorized
end

#streamsObject

Returns the value of attribute streams


22
23
24
# File 'lib/peatio/mq/events.rb', line 22

def streams
  @streams
end

#userObject

Returns the value of attribute user


22
23
24
# File 'lib/peatio/mq/events.rb', line 22

def user
  @user
end

Class Method Details

.allObject


26
27
28
# File 'lib/peatio/mq/events.rb', line 26

def self.all
  @@all
end

.user(user) ⇒ Object


30
31
32
33
34
35
36
# File 'lib/peatio/mq/events.rb', line 30

def self.user(user)
  @@all.each do |handler|
    if handler.user == user
      yield handler
    end
  end
end

Instance Method Details

#send_payload(message) ⇒ Object


48
49
50
# File 'lib/peatio/mq/events.rb', line 48

def send_payload(message)
  @socket.send message.to_json
end