Sha256: d5bb6ec3424261c9b1c142c03dc583e130a8bbdc6dafe2ae5e6f425cb7a6112b

Contents?: true

Size: 702 Bytes

Versions: 4

Compression:

Stored size: 702 Bytes

Contents

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
      # @private
      def receive_data data
        (@buf ||= '') << data

        @buf.each_line do |line|
          if line[-1] == "\n"
            receive_line(line.chomp)
          else
            @buf = line
          end
        end
      end

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
eventmachine-mkroman-1.3.0.dev.1 lib/em/protocols/line_protocol.rb
wj_eventmachine-1.3.2 lib/em/protocols/line_protocol.rb
wj_eventmachine-1.3.1 lib/em/protocols/line_protocol.rb
wj_eventmachine-1.3.0.dev.1 lib/em/protocols/line_protocol.rb