update oqs action cable for order cahnnel and oqs channel

This commit is contained in:
Aung Myo
2017-09-05 09:41:05 +06:30
parent d715809b20
commit eeb2a91ce9
12 changed files with 261 additions and 108 deletions

View File

@@ -1,9 +1,8 @@
class OrderBroadcastJob < ApplicationJob
queue_as :default
def perform(message)
order = Order.find(message) # message come as order_id
ApplicationCable.server.broadcast "order_queue_station_channel", order: order
def perform(table)
ActionCable.server.broadcast "order_channel",table: table
end
end

View File

@@ -5,17 +5,23 @@ class OrderQueueProcessorJob < ApplicationJob
# Do something later
#Order ID
order = Order.find(order_id)
ActionCable.server.broadcast "order_queue_station_channel",message: order
order = Order.find(order_id)
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
#Loop through the order stations and process the items
#Execute orders and send to order stations
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id)
end
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
# private
# def render_order(assign_order)
# ApplicationController.renderer.render(partial: 'oqs/oqs_test',
# locals: { order: assign_order})
# end
# Read more at https://www.pluralsight.com/guides/ruby-ruby-on-rails/creating-a-chat-using-rails-action-cable#TehYiuqlHDOXaQQk.99
end