Class: Dizby::BasicClient

Inherits:
Messenger show all
Defined in:
lib/dizby/stream/client.rb

Instance Attribute Summary

Attributes inherited from Messenger

#remote_uri, #server

Instance Method Summary collapse

Methods inherited from Messenger

#close, #closed?

Methods included from WritableStream

#dump_data, #dump_obj, #make_distributed, #write

Methods included from ReadableStream

#check_packet_size, #load_obj, #load_packet, #load_size, #read

Constructor Details

#initialize(server, stream, remote_uri) ⇒ BasicClient

Returns a new instance of BasicClient.


6
7
8
9
10
11
12
13
# File 'lib/dizby/stream/client.rb', line 6

def initialize(server, stream, remote_uri)
  super(server, stream)

  @remote_uri = remote_uri

  # write the other side's remote_uri to the socket
  write(dump_data(@remote_uri))
end

Instance Method Details

#recv_reply


21
22
23
24
# File 'lib/dizby/stream/client.rb', line 21

def recv_reply
  succ, result = 2.times.map { read }
  [succ, result]
end

#send_request(ref, msg_id, *args, &block)


15
16
17
18
19
# File 'lib/dizby/stream/client.rb', line 15

def send_request(ref, msg_id, *args, &block)
  arr = [ref, msg_id.id2name, args.length, *args, block]
  arr.map! { |ele| dump_data(ele) }
  write(arr.join(''))
end