steveseguin / social_stream

Consolidate your live social messaging streams and much more
http://socialstream.ninja/
GNU General Public License v3.0
516 stars 74 forks source link

Web socket to get current active message? #239

Open chrisspiegl opened 1 month ago

chrisspiegl commented 1 month ago

Is there an option to get the current selected / shown message to be able to display a status "has active message" in a stream deck with the generic web socket plugin, for example?

Basically: similar to the web socket command getQueueSize is there something similar to display if there is an active message which one may want to clear?

Thank you, Chris

steveseguin commented 1 month ago

The featured chat page does not communicate when a message has been removed; at least not with the dock or extension. Given how you can have multiple featured chat pages open, there isn't really a central state.

The dock can track what the last message it featured was, and what messages were past featured.

The extension can auto-feature all messages as well, as can the API, so there is no clear point of featured message state here.

It's possible to listen to the websocket API, assuming the featured chat page is in server (wss) mode, in which case you can monitor what messages have been featured, and whether there was a message-clear event sent. (message = false, essentially). This won't account for if a message self-expires after a certain amount of time.

Beyond that, something would need to be added to accomplish what you want. More clarification needs to be provided to ensure it works correctly. Is it the dock, extension, or featured page that you want to be the source of state truth?

chrisspiegl commented 4 weeks ago

Ok, I understand the challenge here.

I got something working (kind of) with the Custom Web Socket Module, triggers, and internal variables. Basically, trying to keep track of the last featured message (in my case, it's only ever going to be one featured overlay box).

One more question regarding the Web Socket thing.

It appears to me that the web socket is constantly closing / re-opening with an error. Despite sending the “Join” command.

The same also happens when I use the URL with the SESSIONID and IN/OUT Channels.

Xnapper-2024-06-06-10 57 39

Is there a trick to prevent these disconnects?

When I set Companion to “Do not reconnect” it appears to “hold longer” but then eventually still ends up disconnecting, and then it does not auto-reconnect (which I would rather not worry about in the middle of a stream).

The connection sometimes ends with 1006 and sometimes with 1000.

chrisspiegl commented 4 weeks ago

I reduced the occurrence of the closed web socket by setting a delay on the sending of the {"join"… command. Maybe it was not ready to receive it and hence, the socket closed with code 1000 which I apparently means:

      1000 indicates a normal closure, meaning that the purpose for
      which the connection was established has been fulfilled.

However, I am still finding 1006 closures errors… which (with reconnect) turned on in Companion makes the web socket re-establish after 5 seconds, but I'd prefer it to just stay connected TBH.

Do you have any ideas what is going on here? Why is the socket closed?

I'm still trying to understand/learn the whole web socket thing with companion 🙈.

Example trigger to send the join command and instantly ask for the queue size (both on delays so that the connection can first be established)

Xnapper-2024-06-06-15 12 01