Module: IProto::ConnectionAPI

Included in:
EMConnection, TCPSocket
Defined in:
lib/iproto/connection_api.rb

Constant Summary collapse

DEFAULT_RECONNECT =
0.1
HEADER_SIZE =
12
EMPTY_STR =
''.b.freeze
BINARY =
::Encoding::BINARY
PING =
0xff00
PING_ID =
0xffffffff

Instance Method Summary collapse

Instance Method Details

#next_request_idObject



10
11
12
# File 'lib/iproto/connection_api.rb', line 10

def next_request_id
  @next_request_id = ((@next_request_id ||= 0) + 1) & 0x7fffffff
end

#pack_request(request_type, request_id, body) ⇒ Object



19
20
21
22
# File 'lib/iproto/connection_api.rb', line 19

def pack_request(request_type, request_id, body)
  data = ::BinUtils.append_int32_le!(nil, request_type, body.bytesize, request_id)
  ::BinUtils.append_string!(data, body)
end

#send_request(request_id, data) ⇒ Object



14
15
16
# File 'lib/iproto/connection_api.rb', line 14

def send_request(request_id, data)
  # for override
end