Class: Meshchat::Network::Remote::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/meshchat/network/remote/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dispatcher, message_factory) ⇒ Connection

Returns a new instance of Connection.



9
10
11
12
13
# File 'lib/meshchat/network/remote/connection.rb', line 9

def initialize(dispatcher, message_factory)
  @_message_factory = message_factory
  @_message_dispatcher = dispatcher
  @_relay_pool = RelayPool.new(dispatcher)
end

Instance Attribute Details

#_message_dispatcherObject (readonly)

Returns the value of attribute _message_dispatcher.



6
7
8
# File 'lib/meshchat/network/remote/connection.rb', line 6

def _message_dispatcher
  @_message_dispatcher
end

#_message_factoryObject (readonly)

Returns the value of attribute _message_factory.



6
7
8
# File 'lib/meshchat/network/remote/connection.rb', line 6

def _message_factory
  @_message_factory
end

#_relay_poolObject (readonly)

Returns the value of attribute _relay_pool.



7
8
9
# File 'lib/meshchat/network/remote/connection.rb', line 7

def _relay_pool
  @_relay_pool
end

Instance Method Details

#payload_for(to, encrypted_message) ⇒ Object

Parameters:

  • to (String)
    • the uid of the person we are sending to

  • message (String)
    • the encrypted message



23
24
25
# File 'lib/meshchat/network/remote/connection.rb', line 23

def payload_for(to, encrypted_message)
  { to: to, message: encrypted_message }
end

#send_message(node, encrypted_message) ⇒ Object



15
16
17
18
19
# File 'lib/meshchat/network/remote/connection.rb', line 15

def send_message(node, encrypted_message)
  Debug.sending_message_over_relay(node, _relay_pool)
  payload = payload_for(node.uid, encrypted_message)
  _relay_pool.send_payload(payload)
end