indexing description: "Base class for client/application nodes (basically every node except the core)." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" deferred class O_NODE_CLIENT inherit O_NODE redefine switches, peer_module, register_message_handlers end O_SYSTEM_CONSTANTS feature -- Message sending send_message_core (a_message: O_MESSAGE) is -- Send a_message to the core. require a_message_ok: a_message /= Void peer_module_set: peer_module /= Void do if not peer_module.send_message_core (a_message) then origo_logger.error ("Could not send message.") end end feature -- Access peer_module: O_P2P_MODULE_CLIENT -- Peer module. peer_name: STRING is -- Node/peer name. once Result := option_of_name (name_switch).value end feature {NONE} -- Argument handling switches: ARRAYED_LIST [ARGUMENT_SWITCH] is -- Comand line switches. once Result := Precursor Result.extend (create {ARGUMENT_VALUE_SWITCH}.make (name_switch, "Node name", False, False, "NAME", "Name of the node.", False)) end name_switch: STRING is "n" feature {NONE} -- Implementation status_output: STRING is -- Debug output about this node. do create Result.make (512) Result.append ("Name: ") Result.append (name) Result.append_character ('%N') Result.append ("Version: ") Result.append (version) Result.append_character ('%N') Result.append ("Start Time: ") Result.append (start_time.formatted_out ("yyyy-[0]mm-[0]dd [0]hh:[0]mi:[0]ss.ff3")) Result.append ("(UTC)%N") Result.append ("Log Level: ") Result.append (log_level.level_str) Result.append_character ('%N') Result.append ("Listen: ") Result.append (listen_address) Result.append_character ('%N') Result.append ("Peer Name: ") Result.append (peer_name) Result.append_character ('%N') Result.append ("Peer Description: ") Result.append (peer_description) Result.append_character ('%N') Result.append ("Peer ID: ") Result.append (opg.peer_id.out) Result.append_character ('%N') ensure Result_not_void: Result /= Void end peergroup_loader (a_pg: P2P_PEERGROUP; an_id: P2P_ID; a_mia: P2P_MODULE_IMPLEMENTATION_ADVERTISEMENT): P2P_MODULE is -- Load OPG do if a_pg = vampeer and an_id.is_equal (origo_peergroup_id) and origo_peergroup_msid.is_equal (a_mia.specification_id) then create {O_PEERGROUP_CLIENT} Result.init (a_pg, an_id, a_mia) end end register_message_handlers is -- Register message handlers do Precursor register_message_handler (system_namespace, system_status_type, agent (a_msg: O_MESSAGE) local l_msg: O_GENERAL_STRING_MESSAGE do create l_msg.make (status_output) send_message_reply (l_msg, a_msg) end) end end