0

I`m trying to migrate from Actioncable to Anycable. This works perfect with action cable. But it does not work with any, looks like callback does not work. I saw in documentation that it probably should not work with any. What is the best practice to handle such cases?

class NotificationChannel < ApplicationCable::Channel
  def subscribed
    stream_for non_session_user
    return unless non_session_user

    NotificationChannel.broadcast_to(non_session_user, {'name' => 'lastname'})
  end
end

I see that it broadcasting, but nothing on client side. Looks like it broadcasting before get confirmation channel

[AnyCable sid=rc6zCRShb17OuI_OHjqHb] RPC Command: <AnyCable::CommandMessage: command: "subscribe", identifier: "{"channel":"NotificationChannel"}", connection_identifiers: "{"non_session_user":"Z2lkOi8vYW55Y2FibGUvVXNlci8x"}", data: "", env: <AnyCable::Env: url: "http://localhost:8080/cable", headers: {"REMOTE_ADDR"=>"127.0.0.1", "cookie"=>""}, cstate: {}, istate: {}>>
[AnyCable sid=rc6zCRShb17OuI_OHjqHb]   News Load (1.1ms)  SELECT "news".* FROM "news" WHERE "news"."user_id" = $1  [["user_id", 12949]]
[AnyCable sid=rc6zCRShb17OuI_OHjqHb]    (1.9ms)  SELECT COUNT(*) FROM "notifications" WHERE "notifications"."user_id" = $1 AND "notifications"."read" = $2 AND "notifications"."notification_type" = $3  [["user_id", 12949], ["read", false], ["notification_type", "creation_liked"]]
[AnyCable sid=rc6zCRShb17OuI_OHjqHb]    (0.4ms)  SELECT COUNT(*) FROM "notifications" WHERE "notifications"."user_id" = $1 AND "notifications"."read" = $2 AND "notifications"."notification_type" = $3  [["user_id", 12949], ["read", false], ["notification_type", "friend_request"]]
[AnyCable sid=rc6zCRShb17OuI_OHjqHb]    (1.3ms)  SELECT COUNT(*) FROM "users_awards" WHERE "users_awards"."user_id" = $1 AND "users_awards"."viewed" = $2  [["user_id", 12949], ["viewed", false]]
[AnyCable sid=rc6zCRShb17OuI_OHjqHb] [ActionCable] Broadcasting to notification:Z2lkOi8vYW55Y2FibGUvVXNlci8x:  {'name' => 'lastname'}
[AnyCable sid=rc6zCRShb17OuI_OHjqHb] NotificationChannel is transmitting the subscription confirmation

0 Answers0