Class: Ocpp::Rails::MessageHandler
- Inherits:
-
Object
- Object
- Ocpp::Rails::MessageHandler
- Defined in:
- app/services/ocpp/rails/message_handler.rb
Instance Attribute Summary collapse
-
#charge_point ⇒ Object
readonly
Returns the value of attribute charge_point.
-
#raw_message ⇒ Object
readonly
Returns the value of attribute raw_message.
Instance Method Summary collapse
-
#initialize(charge_point, raw_message) ⇒ MessageHandler
constructor
A new instance of MessageHandler.
- #process ⇒ Object
Constructor Details
#initialize(charge_point, raw_message) ⇒ MessageHandler
Returns a new instance of MessageHandler.
6 7 8 9 |
# File 'app/services/ocpp/rails/message_handler.rb', line 6 def initialize(charge_point, ) @charge_point = charge_point @raw_message = end |
Instance Attribute Details
#charge_point ⇒ Object (readonly)
Returns the value of attribute charge_point.
4 5 6 |
# File 'app/services/ocpp/rails/message_handler.rb', line 4 def charge_point @charge_point end |
#raw_message ⇒ Object (readonly)
Returns the value of attribute raw_message.
4 5 6 |
# File 'app/services/ocpp/rails/message_handler.rb', line 4 def @raw_message end |
Instance Method Details
#process ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/ocpp/rails/message_handler.rb', line 11 def process parsed = Protocol.parse() case parsed[:type] when "CALL" handle_call(parsed) when "CALLRESULT" handle_callresult(parsed) when "CALLERROR" handle_callerror(parsed) when "PARSE_ERROR" log_error("Failed to parse message: #{parsed[:error]}") send_callerror(SecureRandom.uuid, "FormationViolation", "Invalid JSON format") when "UNKNOWN" log_error("Unknown message type: #{parsed[:raw]}") send_callerror(SecureRandom.uuid, "ProtocolError", "Unknown message type") end rescue => e send_internal_error(parsed && parsed[:message_id], e, "Error processing message") end |