Skip to content

Commit

Permalink
simple EM::P::LineProtocol
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Jul 19, 2010
1 parent 7f20dba commit 4e9011d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/em/protocols.rb
Expand Up @@ -5,7 +5,7 @@ module EventMachine
# - Memcache
# - SmtpClient and SmtpServer
# - SASLauth and SASLauthclient
# - LineAndTextProtocol and LineText2
# - LineProtocol, LineAndTextProtocol and LineText2
# - HeaderAndContentProtocol
# - Postgres3
# - ObjectProtocol
Expand Down
28 changes: 28 additions & 0 deletions lib/em/protocols/line_protocol.rb
@@ -0,0 +1,28 @@
module EventMachine
module Protocols
# 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
#
module LineProtocol
def receive_data data # :nodoc:
(@buf ||= '') << data

while line = @buf.slice!(/(.*)\r?\n/)
receive_line(line)
end
end

# Invoked with lines received over the network
def receive_line(line)
# stub
end
end
end
end

0 comments on commit 4e9011d

Please sign in to comment.