Jump to content

Handling real-time library updates to the client


roblav96

Recommended Posts

roblav96

TLDR

How does the server tell a client to re-render library content?

 

A few example use-cases are:

  • client searches for library media, server dynamically adds media to library, client never receives library updates until they type the next word
  • client views a library item, server dynamically downloads subtitles for library item, client never receives subtitle updates until they press back and view the library item again

Things I've tried:

  • POST /Library/Media/Updated only downloads metadata for parameters in the request body
  • POST /Sessions/{Id}/Message/LibraryChanged command but the clients never receive a websocket message, the only time I've witnesses the client receive a LibraryChanged message is a full minute after a library scan is completed, would be nice to manually send this command immediately after the library scan

Issues I've come across:

  • Roku clients never receive updates of any kind from the server, most likely related to using roku's native remote control api which is restricted to same subnet ip addresses
Link to comment
Share on other sites

  • 2 weeks later...

The server tells the clients via the websocket LibraryChanged messages, and yes, that can take a minute or so after the change actually happens.

 

 

 

POST /Library/Media/Updated only downloads metadata for parameters in the request body

This tells the server that a file changed, which then feeds that notification into the same place that the realtime monitor notifies. And then eventually later this will send LibraryChanged if something in the database was updated as a result of the file changes.

 

 

 

client searches for library media, server dynamically adds media to library, client never receives library updates until they type the next word

When does the server dynamically add media?

Link to comment
Share on other sites

roblav96

Is there anyway I can manually send the LibraryChanged event to clients via websocket on the server?

 

I've tried something like:

await Session.command('LibraryChanged', {
	CollectionFolders: [],
	FoldersAddedTo: ['4'],
	FoldersRemovedFrom: [],
	IsEmpty: false,
	ItemsAdded: [],
	ItemsRemoved: [],
	ItemsUpdated: Items.map(v => v.Id),
})

but the clients never received.

 

The server dynamically adds media from my search plugin:

https://github.com/roblav96/futon-media/blob/ba65f92d1589138bcccbb08e153dc3da949ad933/src/emby/search.ts#L98

Link to comment
Share on other sites

No, you can't force that to be sent out. You should use /Library/Media/Updated. This will tell the server that files were changed, and eventually this will lead to LibraryChanged messages getting sent out.

 

Having said that, I'm not sure what your code is doing, but if it's creating or editing strm files then you might just be able to enable the realtime monitor and let that do the work for you of notifying the apps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...