Module: EventMachine::Protocols::LineProtocol
- Defined in:
- lib/em/protocols/line_protocol.rb
Overview
LineProtocol will parse out newline terminated strings from a receive_data stream
module Server
include EM::P::LineProtocol
def receive_line(line)
send_data("you said: #{line}")
end
end
Instance Method Summary collapse
- #receive_data(data) ⇒ Object
-
#receive_line(line) ⇒ Object
Invoked with lines received over the network.
Instance Method Details
#receive_data(data) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/em/protocols/line_protocol.rb', line 15 def receive_data data (@buf ||= '') << data while @buf.slice!(/(.*?)\r?\n/) receive_line($1) end end |
#receive_line(line) ⇒ Object
Invoked with lines received over the network
24 25 26 |
# File 'lib/em/protocols/line_protocol.rb', line 24 def receive_line(line) # stub end |