Class: Push::Transport::Controller::WebSocket

Inherits:
Cramp::Websocket
  • Object
show all
Includes:
Logger
Defined in:
lib/push/transport/controller/web_socket.rb

Instance Method Summary collapse

Instance Method Details

#bind_queueObject



9
10
11
12
13
14
15
16
# File 'lib/push/transport/controller/web_socket.rb', line 9

def bind_queue
  logger.info "Subscribed to '#{exchange}'"
  queue.bind(channel.fanout(exchange)).subscribe(:ack => true) {|header, message|
    header.ack
    render message
    logger.info "Sent message: #{message}"
  }
end

#message_received(data) ⇒ Object



25
26
27
# File 'lib/push/transport/controller/web_socket.rb', line 25

def message_received(data)
  logger.info "Received #{data}" # Who cares? Do nothing.
end

#unbind_queueObject



18
19
20
21
22
23
# File 'lib/push/transport/controller/web_socket.rb', line 18

def unbind_queue
  queue.unsubscribe {
    channel.close
    logger.info "Unsubscribed from '#{exchange}'"
  }
end