Sha256: 3b143422a4debc5bae1f0eda57f52d7028af43092d8a4be74ffd35617aaedffd

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

require 'protobuf/rpc/server'

module Protobuf
  module Rpc
    module Evented
      class Server < ::EventMachine::Connection
        include ::Protobuf::Rpc::Server
        include ::Protobuf::Logger::LogMethods

        # Initialize a new read buffer for storing client request info
        def post_init
          initialize_request!
          @request_buffer = Protobuf::Rpc::Buffer.new(:read)
        end

        # Receive a chunk of data, potentially flushed to handle_client
        def receive_data(data)
          log_debug { sign_message("receive_data: #{data}") }

          @request_buffer << data
          @request_data = @request_buffer.data

          handle_client if @request_buffer.flushed?
        end

        def send_data
          response_buffer = Protobuf::Rpc::Buffer.new(:write)
          response_buffer.set_data(@response)
          @stats.response_size = response_buffer.size
          log_debug { sign_message("sending data: #{response_buffer.inspect}") }
          super(response_buffer.write)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
protobuf-2.8.13 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.12 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.11 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.10 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.9 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.8 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.7 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.6 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.5 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.4 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.3 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.2 lib/protobuf/rpc/servers/evented/server.rb
protobuf-2.8.1 lib/protobuf/rpc/servers/evented/server.rb