Class: LanGrove::Client::Base

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/langrove/client_base.rb

Direct Known Subclasses

Datagram

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config.



31
32
33
# File 'lib/langrove/client_base.rb', line 31

def config
  @config
end

#handlerObject

Misnomer.

This is not the client,

It is the server’s perspective of the client,

These are generally stored in the daemon’s handler collection,

Which contains this and all similar clients,

Each bonded through the daemon’s connection adaptor to the socket that couples them to their actual client..



29
30
31
# File 'lib/langrove/client_base.rb', line 29

def handler
  @handler
end

#loggerObject

Returns the value of attribute logger.



32
33
34
# File 'lib/langrove/client_base.rb', line 32

def logger
  @logger
end

#protocolObject

Returns the value of attribute protocol.



30
31
32
# File 'lib/langrove/client_base.rb', line 30

def protocol
  @protocol
end

Instance Method Details

#receive(decoded_data) ⇒ Object

Data arriving through the Adaptor is passed through the config assigned protocol and then arrives here in whatever format the <Protocol>.decode() method returned.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/langrove/client_base.rb', line 49

def receive( decoded_data ) 

  #
  # OVERRIDE
  # 
  #   - Inbound data arrived at the adaptor
  #
  #   - It has passed through the protocol as
  #     defined in config.
  #
  #     The protocol should have arranged the data 
  #     into a Hash of: 
  #  
  #       - key and value pairs
  # 
  #       - key and more_complicated_thing pairs.
  # 
  #   - The decoded data was then passed into
  #     this function.
  #
  # 

end

#receive_data(data) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/langrove/client_base.rb', line 73

def receive_data( data )
  
  #
  # Event machine writes into here at receiving data 
  # from the client. 
  # 
  
  receive( @protocol.decode( data ) )
  
  # 
  # ?Multi-message protocol? 
  # 
  # @protocol.accumulate( multi_message_part, self )
  #
  #   ---- With protocol responding directly to source
  # 
  #   ---- With protocol then calling receive_decoded()
  #        via the self being passed in. 
  #   
  
end

#start_clientObject



34
35
36
# File 'lib/langrove/client_base.rb', line 34

def start_client
  @logger.debug 'start_client called'
end

#stop_clientObject



38
39
40
# File 'lib/langrove/client_base.rb', line 38

def stop_client
  @logger.debug 'stop_client called'
end