Browse API "multi_session_key" usage

How is multi_session_key used by ROON server software ?
Does it influence the creation of the item_keys ?
Can it help to avoid InvalidItemKey errors ? If yes must multi_session_key be introduced at root level ?

I know that the item_keys are temporary and should be used only to drill down. What exactly is the criteria that an item_key becomes invalid ?

Sorry, many questions. :slightly_smiling_face:
I think many developers would be very happy if item_keys would be valid for a longer period.

The way I understand it is the following:

As you know, item_key changes (increases by 1) everytime the browse api is called.

This works well as long as you have 1 client accessing the api.

Once another client calls the api, the item_key is not in sync with the first client anymore. This is where you get the invalid_ key error message.

So to fix this, multi_session_key is used so that each clients can have their own session keys.

The best time to start using the multi_ session_ key is when the client first connects to the server.

I’m managing it at the client side. Create the multi session key when the page first opens and carry It on the subsequent url calls.
On second thought if you are using websocket, you can manage it on the server Side by creating it on “on connect”.

You can see it Here

2 files of interest are:

  • browser.js where I create the session key, and
  • apps.js where it is used.

Hope it helps

Bastian, thank you for quick answer. I know your ws_player. It is very helpful sample.

My problem is related with temporary item keys.

As result of a search / browse I get a tree like

  • “artists”
    • artist 1
    • artist n
  • “albums”
    • album 1
    • album n
  • “tracks”
    • track 1
    • track n

The problem is that I have to return the whole tree including the (temporary) item keys which are not
valid any more when track 1 should be played.

My idea was to use different multi_session_keys for the artists, albums, tracks subtrees in the hope to avoid the InvalidItemKey error.

I have not tried that but I doubt it will work as the server will not know where you are after changing the multi_session_keys

Would the “up” call work for this? If it does, you can store the level where you are now, and call the up call few times to get where want to be. For example, if you are in tracks level, calling up twice should get you to the artist info.

Another option is to store your clicks from the top.
For example, if you do a search, and click on the 2nd result. Log the search and then the second entry from the result list and so on. It should get you to the same place too.

Thank you. I also was thinking about storing the item indexes.