Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849class Api::V4::WebsocketMessage attr_reader :type, :data
TYPES = %w[ connection_error fatal_error global_state race_created race_started race_updated
race_not_found race_invalid_join_token race_state
race_start_scheduled race_ended
race_entries_updated
new_message
new_attachment new_card
run_state run_parsed run_not_found cant_parse_run ].freeze
HTML_TYPES = TYPES.map { |t| "#{t}:html" }.freeze
def initialize(type, **data) raise "Invalid type #{type}" unless TYPES.include?(type) || HTML_TYPES.include?(type) raise '"message" required as keyword argument' if data[:message].blank?
@type = type @data = data end
def to_h { type: @type, data: @data } endend