Class: Dizby::Messenger

Inherits:
Object
  • Object
show all
Includes:
ReadableStream, WritableStream
Defined in:
lib/dizby/stream/messenger.rb

Direct Known Subclasses

BasicClient, BasicConnection

Instance Attribute Summary collapse

Instance Method Summary collapse

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) ⇒ Messenger

Returns a new instance of Messenger.


10
11
12
13
14
15
16
# File 'lib/dizby/stream/messenger.rb', line 10

def initialize(server, stream)
  @server = server

  # stream needs to have the read(int), write(str), and close() methods
  # this value can be overloaded in the client/server classes for a protocol
  @stream = stream
end

Instance Attribute Details

#remote_uri (readonly)

Returns the value of attribute remote_uri


18
19
20
# File 'lib/dizby/stream/messenger.rb', line 18

def remote_uri
  @remote_uri
end

#server (readonly)

Returns the value of attribute server


18
19
20
# File 'lib/dizby/stream/messenger.rb', line 18

def server
  @server
end

Instance Method Details

#close


20
21
22
# File 'lib/dizby/stream/messenger.rb', line 20

def close
  @stream.close
end

#closed?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/dizby/stream/messenger.rb', line 24

def closed?
  !@stream || @stream.closed?
end