EventMachine::Protocols::ObjectProtocol

ObjectProtocol allows for easy communication using marshaled ruby objects

 module RubyServer
   include EM::P::ObjectProtocol

   def receive_object obj
     send_object({'you said' => obj})
   end
 end

Public Instance Methods

receive_object(obj) click to toggle source

Invoked with ruby objects received over the network

    # File lib/em/protocols/object_protocol.rb, line 34
34:       def receive_object obj
35:         # stub
36:       end
send_object(obj) click to toggle source

Sends a ruby object over the network

    # File lib/em/protocols/object_protocol.rb, line 39
39:       def send_object obj
40:         data = serializer.dump(obj)
41:         send_data [data.respond_to?(:bytesize) ? data.bytesize : data.size, data].pack('Na*')
42:       end
serializer() click to toggle source

By default returns Marshal, override to return JSON or YAML, or any other serializer/deserializer responding to # and #.

    # File lib/em/protocols/object_protocol.rb, line 16
16:       def serializer
17:         Marshal
18:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.