Class: Funnel::WebSocket::Connection

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/funnel/web_socket/connection.rb

Direct Known Subclasses

Routing::Router, Servers::DummyServer

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



6
7
8
# File 'lib/funnel/web_socket/connection.rb', line 6

def headers
  @headers
end

Instance Method Details

#cookiesObject

helper methods



12
13
14
# File 'lib/funnel/web_socket/connection.rb', line 12

def cookies
	@headers[:cookies]
end

#hostObject



16
17
18
# File 'lib/funnel/web_socket/connection.rb', line 16

def host
  @headers[:host]
end

#on_data(data) ⇒ Object

override this



45
46
47
# File 'lib/funnel/web_socket/connection.rb', line 45

def on_data data
  puts "Data"
end

#on_disconnectObject

override this



40
41
42
# File 'lib/funnel/web_socket/connection.rb', line 40

def on_disconnect
  puts "Disconnect"
end

#on_readyObject

override this



35
36
37
# File 'lib/funnel/web_socket/connection.rb', line 35

def on_ready
  puts "Connect"
end

#originObject



20
21
22
# File 'lib/funnel/web_socket/connection.rb', line 20

def origin
  @headers[:origin]
end

#pathObject



24
25
26
# File 'lib/funnel/web_socket/connection.rb', line 24

def path
  @headers[:path]
end

#post_initObject

called from EM



55
56
57
58
# File 'lib/funnel/web_socket/connection.rb', line 55

def post_init
  @headers = {}
  on_ready
end

#protocolObject



28
29
30
# File 'lib/funnel/web_socket/connection.rb', line 28

def protocol
  @headers[:websocket_protocol]
end

#receive_data(data) ⇒ Object

called from EM



61
62
63
# File 'lib/funnel/web_socket/connection.rb', line 61

def receive_data data
  on_data Frame.decode(data)
end

#send_message(msg) ⇒ Object



65
66
67
# File 'lib/funnel/web_socket/connection.rb', line 65

def send_message msg
  send_data Frame.encode(msg)
end

#unbindObject

called from EM



50
51
52
# File 'lib/funnel/web_socket/connection.rb', line 50

def unbind
  on_disconnect
end