Class: Webmate::SocketIO::Actions::Handshake

Inherits:
Object
  • Object
show all
Defined in:
lib/webmate/socket.io/actions/handshake.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Handshake

Returns a new instance of Handshake.



5
6
7
8
9
10
11
12
13
14
# File 'lib/webmate/socket.io/actions/handshake.rb', line 5

def initialize(options = {})
  @session_id = generate_session_id

  default_options = {
    transports: %w{websocket},
    heartbeat_timeout: 300,
    closing_timeout: 300
  }
  @settings = OpenStruct.new(default_options.merge(options))
end

Instance Method Details

#respondObject



16
17
18
19
20
21
22
23
24
# File 'lib/webmate/socket.io/actions/handshake.rb', line 16

def respond
  body = [
    @session_id,
    @settings.heartbeat_timeout,
    @settings.closing_timeout,
    @settings.transports.join(',')
  ]
  Webmate::Responders::Response.new(body.join(':'))
end