Class: Meshchat::Network::Dispatcher
- Inherits:
-
Object
- Object
- Meshchat::Network::Dispatcher
- Defined in:
- lib/meshchat/network/dispatcher.rb
Instance Attribute Summary collapse
-
#_local_client ⇒ Object
readonly
standard peer-to-peer message sending.
-
#_message_factory ⇒ Object
readonly
creates messages.
-
#_relay_client ⇒ Object
readonly
the action cable client ( web socket / connection beyond the firewall) - responsible for the relay server if the http client can’t find the recipient.
Instance Method Summary collapse
-
#initialize ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #send_message(location: nil, uid: nil, node: nil, message: nil) ⇒ Object
- #send_to_all(message, ignore_offline_status: false) ⇒ Object
Constructor Details
#initialize ⇒ Dispatcher
Returns a new instance of Dispatcher.
15 16 17 18 19 |
# File 'lib/meshchat/network/dispatcher.rb', line 15 def initialize @_message_factory = Message::Factory.new(self) @_local_client = Local::Connection.new(self, @_message_factory) @_relay_client = Remote::Connection.new(self, @_message_factory) end |
Instance Attribute Details
#_local_client ⇒ Object (readonly)
standard peer-to-peer message sending
9 10 11 |
# File 'lib/meshchat/network/dispatcher.rb', line 9 def _local_client @_local_client end |
#_message_factory ⇒ Object (readonly)
creates messages
6 7 8 |
# File 'lib/meshchat/network/dispatcher.rb', line 6 def @_message_factory end |
#_relay_client ⇒ Object (readonly)
the action cable client ( web socket / connection beyond the firewall)
- responsible for the relay server if the http client can't find the recipient
13 14 15 |
# File 'lib/meshchat/network/dispatcher.rb', line 13 def _relay_client @_relay_client end |
Instance Method Details
#send_message(location: nil, uid: nil, node: nil, message: nil) ⇒ Object
Note:
Either the location, node, or uid should be present
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/meshchat/network/dispatcher.rb', line 27 def (location: nil, uid: nil, node: nil, message: nil) # verify node is valid node = Node.for(location: location, uid: uid, node: node) # don't proceed if we don't have a node return unless node # don't send to ourselves return if APP_CONFIG.user['uid'] == node.uid # everything is valid so far... DISPATCH! dispatch!(node, ) end |