0

I identify connections by public IP address. My understanding until recently (doubting it) is that in such a case, client's subscribing to a channel would reuse the same Channel instance.

A real world example is as follows:

I'm building up an app that requests information from a certain source that is not owned by me. This is done through an HTTP request and a Job. The external resource changes in periodic intervals of time.

My DataChannel class, which inherits from ApplicationCable::Channel manages a cache of the last request so new clients subscribed from the same IP address won't start a new request, but instead reuse the last one.

Summing up:

If I open two tabs and each one subscribes to a channel, do I get two Channel instances even if the connection identifier is the same?

I'm not seeking for a way to do so, just pointing me in the right direction is enough and actually far more valuable.

42linoge
  • 26
  • 5
  • It seems like they are not, it's because I'm in development environment, I'll test it with production. As per what I wanted to do, I ended up using Redis DLM. – 42linoge Feb 18 '17 at 22:47

1 Answers1

0

No, they aren't.

I needed to add some synchronization between all instances owned by a client with connection identified with IP address.

For this, I used Redis DLM, so I could acquire and release locks and thus perform computations which were intended to be unique.

There might be a better way to do so, but I couldn't imagine one that didn't require patching the ActionCable sources. Any further comment is appreciated as always.

42linoge
  • 26
  • 5