Class: E4z::SocketClient

Inherits:
Object
  • Object
show all
Defined in:
lib/socket_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(project_slug) ⇒ SocketClient



5
6
7
8
9
10
11
12
13
14
# File 'lib/socket_client.rb', line 5

def initialize(project_slug)
  @project_slug = project_slug

  socket.subscribe(@project_slug)
  socket[@project_slug].bind('run_instruction') do |data|
    yield(data)
  end

  socket.connect
end

Instance Method Details

#optionsObject



16
17
18
# File 'lib/socket_client.rb', line 16

def options
  { secure: true }
end

#socketObject



20
21
22
# File 'lib/socket_client.rb', line 20

def socket
  @socket ||= PusherClient::Socket.new(ENV['PUSHER_TOKEN'], options)
end