Class: WildSoNet::Streamer::Handler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#encoderObject

Returns the value of attribute encoder.



9
10
11
# File 'lib/handler.rb', line 9

def encoder
  @encoder
end

Instance Method Details

#channelClosed(context, event) ⇒ Object



31
32
33
# File 'lib/handler.rb', line 31

def channelClosed context, event
  WildSoNet::Streamer::Server.unregister(context.attachment.id, context.attachment)
end

#messageReceived(context, event) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/handler.rb', line 11

def messageReceived context, event

  message = event.getMessage

  if result = /^GET \/streamer\/([a-z]+)\/(.+) HTTP\/1\..$/.match(message)
    connection = Connection.new(context, @encoder)
    connection.type = result[1]
    connection.id = result[2]
    context.attachment = connection
  end

  if message == ""
    context.channel.write("HTTP/1.1 200 OK\r\n")
    context.channel.write("Content-Type: text/html; charset=UTF-8\r\n")
    context.channel.write("\r\n")
    WildSoNet::Streamer::Server.register(context.attachment.id, context.attachment)
  end

end