-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WCA Live Integration Pre Work #1: Job and Websockets #10684
base: main
Are you sure you want to change the base?
Changes from all commits
099cf87
67f96f5
764cf7d
41570b7
8288843
3d3fe29
31aba6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module ApplicationCable | ||
class Channel < ActionCable::Channel::Base | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module ApplicationCable | ||
class Connection < ActionCable::Connection::Base | ||
# For Live we don't care about only letting authenticated users connect | ||
# We might want to change this for other use cases | ||
|
||
# identified_by :current_user | ||
# | ||
def connect | ||
reject_unauthorized_connection if EnvConfig.WCA_LIVE_SITE? | ||
end | ||
# | ||
# private | ||
# | ||
# def find_verified_user | ||
# user_id = cookies.encrypted["_WcaOnRails_session"]["warden.user.user.key"][0] | ||
# if (verified_user = User.find_by(id: user_id)) | ||
# verified_user | ||
# else | ||
# reject_unauthorized_connection | ||
# end | ||
# end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class LiveResultsChannel < ApplicationCable::Channel | ||
def subscribed | ||
stream_from "results_#{params[:round_id]}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shared constant yay |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddLiveResultJob < ApplicationJob | ||
self.queue_adapter = :shoryuken if Rails.env.production? && !EnvConfig.WCA_LIVE_SITE? | ||
queue_as EnvConfig.LIVE_QUEUE if Rails.env.production? && !EnvConfig.WCA_LIVE_SITE? | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move the |
||
|
||
def perform(params) | ||
ActionCable.server.broadcast("results_#{params[:round_id]}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, please share this broadcast key (perhaps in the same module as the "WCA Live enabled?" feature above) |
||
{ attempts: params[:results], user_id: params[:user_id] }) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line with my other comment:
reject unless WcaLive.enabled?