I am trying to build a chat feature for my rails application. I am using ActionController::Live
, Puma
, Resque
, Redis
for this. So far what i have done is whenever a user enters a text in below form field i.e. chat box
<%= form_tag chat_box_publish_path, method: :get do %>
<%= text_field_tag :query, params[:query], class: "form-control", id: "chatSearchBox",
placeholder: 'Search' %>
<% end %>
..the request is coming to Publish
method in ChatBoxController
.
def publish
$redis.publish("chat_message:1:1", "#{params[:query]}")
respond_to do |format|
format.js {render nothing: true}
end
end
..now i have a below background Resque
job running with below code for testing purposes. So whenever a chat message is posted, its printing the data
which is fine. But how can i add ActionController::Live
feature to the background job ? or how do i go about this implementation ? Need help with this design.
class ChatBoxInitiator
@queue = :chat_box_initiator
private
def self.perform
$redis.subscribe('chat_message:1:1') do |on|
on.message do |event, data|
puts "====#{data}"
return data
end
end
end
end
and i want to show the Server Side Events(SSE)
notifications in Users/show
page
Aucun commentaire:
Enregistrer un commentaire