Permalink
Browse files

message2

  • Loading branch information...
sorah committed Oct 22, 2017
1 parent 2ac14b8 commit 332a3c1db6e486c72c56aac07301b7545bfd4b05
Showing with 3 additions and 2 deletions.
  1. +3 −2 isubata/webapp/ruby/app.rb
@@ -32,6 +32,7 @@ def since(id, limit: 100)
class AwesomeFetch
STREAM_KEY = 'isubata:stream:message'
STREAM_KEY2 = 'isubata:stream:message2'
def self.instance
@instance ||= AwesomeFetch.new.tap(&:start)
@@ -71,7 +72,7 @@ def connect_redis
def start
@thread = Thread.new do
redis = connect_redis()
redis.subscribe(STREAM_KEY) do |on|
redis.subscribe(STREAM_KEY, STREAM_KEY2) do |on|
on.subscribe do |ch, subs|
puts "AwesomeFetch subscribed to #{ch.inspect} (#{subs} subscriptions)"
end
@@ -216,7 +217,7 @@ def user
db.query('SELECT id FROM channel').each do |ch|
db.query("SELECT * FROM message WHERE channel_id = #{ch['id']} ORDER BY id DESC LIMIT #{MessageBin::LIMIT}").to_a.reverse_each do |row|
user = all_users.fetch row['user_id']
redis.publish('isubata:stream:message',
redis.publish('isubata:stream:message2',
{
'type' => 'message',
'id' => row['id'],

0 comments on commit 332a3c1

Please sign in to comment.