Class: PDTP::Server::Connection

Inherits:
Protocol show all
Defined in:
lib/pdtp/server/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Protocol

#connection_open?, define_message_params, #error_close_connection, #get_peer_info, #hash_to_range, #initialize, obj_matches_type?, #post_init, print_info, #range_to_hash, #receive_packet, #remote_peer_id, #send_message, #to_s, #unbind, validate_message

Methods inherited from LengthPrefixProtocol

#initialize, #prefix_size=, #receive_data, #receive_packet, #send_packet

Constructor Details

This class inherits a constructor from PDTP::Protocol

Instance Attribute Details

#dispatcherObject

Returns the value of attribute dispatcher.



28
29
30
# File 'lib/pdtp/server/connection.rb', line 28

def dispatcher
  @dispatcher
end

#user_dataObject

Returns the value of attribute user_data.



29
30
31
# File 'lib/pdtp/server/connection.rb', line 29

def user_data
  @user_data
end

Instance Method Details

#connection_completedObject

Raises:

  • (RuntimeError)


41
42
43
44
# File 'lib/pdtp/server/connection.rb', line 41

def connection_completed
  raise(RuntimeError, 'server was never initialized') unless @dispatcher
  @dispatcher.connection_created self
end

#connection_destroyedObject

Raises:

  • (RuntimeError)


46
47
48
49
# File 'lib/pdtp/server/connection.rb', line 46

def connection_destroyed
  raise(RuntimeError, 'server was never initialized') unless @dispatcher
  @dispatcher.connection_destroyed self
end

#file_service?Boolean

Is this connection the file service?

Returns:

  • (Boolean)


32
33
34
# File 'lib/pdtp/server/connection.rb', line 32

def file_service?
  @file_service
end

#mark_as_file_serviceObject

Mark this connection as being a file service



37
38
39
# File 'lib/pdtp/server/connection.rb', line 37

def mark_as_file_service
  @file_service = true
end

#receive_message(command, message) ⇒ Object

Raises:

  • (RuntimeError)


51
52
53
54
# File 'lib/pdtp/server/connection.rb', line 51

def receive_message(command, message)
  raise(RuntimeError, 'server was never initialized') unless @dispatcher
  @dispatcher.dispatch_message command, message, self
end