| Server IP : 217.160.0.244 / Your IP : 216.73.217.138 Web Server : Apache System : Linux infong-eu155 4.4.400-icpu-108 #2 SMP Wed Feb 11 11:51:01 UTC 2026 x86_64 User : u100174116 ( 6746176) PHP Version : 8.5.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/ruby/vendor_ruby/em/protocols/ |
Upload File : |
module EventMachine
module Protocols
# 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
#
module ObjectProtocol
# By default returns Marshal, override to return JSON or YAML, or any
# other serializer/deserializer responding to #dump and #load.
def serializer
Marshal
end
# @private
def receive_data data
(@buf ||= '') << data
while @buf.size >= 4
if @buf.size >= 4+(size=@buf.unpack('N').first)
@buf.slice!(0,4)
receive_object serializer.load(@buf.slice!(0,size))
else
break
end
end
end
# Invoked with ruby objects received over the network
def receive_object obj
# stub
end
# Sends a ruby object over the network
def send_object obj
data = serializer.dump(obj)
send_data [data.respond_to?(:bytesize) ? data.bytesize : data.size, data].pack('Na*')
end
end
end
end