Class: ActionMCP::Session::SSEEvent
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActionMCP::Session::SSEEvent
- Defined in:
- app/models/action_mcp/session/sse_event.rb
Overview
Represents a Server-Sent Event (SSE) in an MCP session These events are stored for potential resumption when a client reconnects
Instance Method Summary collapse
-
#data_for_stream ⇒ Object
Serializes the data as JSON if it’s not already a string.
-
#to_sse ⇒ String
Generates the SSE formatted event string.
Instance Method Details
#data_for_stream ⇒ Object
Serializes the data as JSON if it’s not already a string
49 50 51 52 53 |
# File 'app/models/action_mcp/session/sse_event.rb', line 49 def data_for_stream return data if data.is_a?(String) data.is_a?(Hash) ? data.to_json : data.to_s end |
#to_sse ⇒ String
Generates the SSE formatted event string
57 58 59 |
# File 'app/models/action_mcp/session/sse_event.rb', line 57 def to_sse "id: #{event_id}\ndata: #{data_for_stream}\n\n" end |