Class: WildSoNet::Streamer::Connection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, encoder) ⇒ Connection

Returns a new instance of Connection.



45
46
47
48
# File 'lib/handler.rb', line 45

def initialize context, encoder
  @context = context
  @encoder = encoder
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



43
44
45
# File 'lib/handler.rb', line 43

def context
  @context
end

#idObject

Returns the value of attribute id.



41
42
43
# File 'lib/handler.rb', line 41

def id
  @id
end

#typeObject

Returns the value of attribute type.



42
43
44
# File 'lib/handler.rb', line 42

def type
  @type
end

Instance Method Details

#operationComplete(future) ⇒ Object



61
62
63
# File 'lib/handler.rb', line 61

def operationComplete future
  future.channel.close if future.isDone()
end

#write(data) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/handler.rb', line 50

def write data
  case @type
    when "message"
      data = @encoder.message(data)
      @context.channel.write(data).addListener(self)
    when "script"
      data = @encoder.script(data)
      @context.channel.write(data)
  end
end