Quantcast
Channel: Squeezebox : Community : Forums
Viewing all articles
Browse latest Browse all 10706

LMS 7.8/7.9 Comet - 2 player status subscriptions on single comet connection.

$
0
0
Please forgive me if incorrect forum. Tried posting to Developer forum but don't have access.

I have comet fully functional but have come across an issue and not sure if is a comet or LMS notification. I don't think is a 7.9 bug per se, but may be a limitation of LMS.

I have a single player for which I want to open 2 different status subscriptions so in the code below <PLAYER_MAC> is the same value across #2 and #3.

1. Have a working subscription to serverstatus every 60 seconds. (channel "client/serverStatus")
2. Upon first ServerStatus Notification, if the target player is in the players loop, I open a subscription using channel named "client/playerTime/<PLAYER MAC>" with command <PLAYER_MAC> status - 0 subscribe:10 tags:blah-blah
3. Upon first playerStatus notification from #2 above, if the target player is mode="play", I open a 2nd subscription using channel named "client/playerTime/<PLAYER MAC>" with command <PLAYER_MAC> status - 0 subscribe:1

The intent of Channel #3 is to track only play time when the player is playing. When playback stops, Channel #3 will unsubscribed successfully.

Once steps 1, 2, 3 are complete, I continue to get events for channel #1, I don't receive another notification for Channel #2. I however, receive notifications for Channel #3 until such time as I unsubscribe.

I have observed 2 things. Once channel #3 is established, subscriptions are delivered there. If I unsubscribe Channel #3, then events for #2 are still not delivered. I have to unsubscribe/resubscribe for #2 to get things working again. So, one approach is to switch between 2 subscriptions using the same commands but with different subscribe time values.

The questions I have are as follows:

1. Is there a limitation in the server that, via comet, prevents 2 different player status subscriptions (different parameters/times) from being serviced using single comet connection?
2. If no limitation exist, then does anyone have guidance as to what I need to do here? Are 2 comet channels as mentioned in other threads the only possible solution?

Thoughts appreciated...

Thanks,
Lyndel


Here is the JS code I am using that will hopefully illustrates the 3 registrations I am doing.

function sendServerSubscribe()
{
if (isNaN(serverSubscribeId))
serverSubscribeId = nextCometRequestId();
else
sendServerUnsubscribe();

writeCometHttpMessage(bindReadyStateChangeComplete d(createAndOpenCometRequest()),[createSubscribeRequest(
cometClientId,serverSubscribeId,
"slim/serverStatus",
["", ["serverstatus", 0, 50, 'prefs:libraryname', "subscribe:" + serverSubscribeSeconds]])]);
}
function sendServerUnsubscribe()
{
if (isNaN(serverSubscribeId))
return;

writeCometHttpMessage(bindReadyStateChangeComplete d(createAndOpenCometRequest()),[createUnsubscribeRequest(
cometClientId,serverSubscribeId,
"slim/serverStatus")]);
serverSubscribeId = NaN;
}

function sendPlayerSubscribePlayTime()
{
if (isNaN(playerSubscribeIdPlayTime))
playerSubscribeIdPlayTime = nextCometRequestId();
else
{
sendPlayerUnsubscribePlayTime();
playerSubscribeIdPlayTime = nextCometRequestId();
}
writeCometHttpMessage(bindReadyStateChangeComplete d(createAndOpenCometRequest()),[createSubscribeRequest(
cometClientId,playerSubscribeIdPlayTime,
"slim/playerTime/" + monitoredPlayerId,
[monitoredPlayerId, ["status", "-", 0, "subscribe:1"]])]);
}

function sendPlayerUnsubscribePlayTime()
{
if (isNaN(playerSubscribeIdPlayTime))
return;

writeCometHttpMessage(bindReadyStateChangeComplete d(createAndOpenCometRequest()),
[createUnsubscribeRequest(
cometClientId,playerSubscribeIdPlayTime,
"slim/playerTime/" + monitoredPlayerId)]);
playerSubscribeIdPlayTime = NaN;
}

function sendPlayerSubscribe()
{
if (isNaN(playerSubscribeId))
playerSubscribeId = nextCometRequestId();
else
{
sendPlayerUnsubscribe();
playerSubscribeId = nextCometRequestId();
}
writeCometHttpMessage(bindReadyStateChangeComplete d(createAndOpenCometRequest()),
[createSubscribeRequest(
cometClientId,playerSubscribeId,
"slim/playerStatus/" + monitoredPlayerId,
[monitoredPlayerId, ["status", "-", 1, "subscribe:10", "tags:cgABbehldiqtyrSuoKLNTI"]])]);
}

function sendPlayerUnsubscribe()
{
if (isNaN(playerSubscribeId))
return;
writeCometHttpMessage(bindReadyStateChangeComplete d(createAndOpenCometRequest()),
[createUnsubscribeRequest(
cometClientId,playerSubscribeId,
"slim/playerStatus/" + monitoredPlayerId)]);

playerSubscribeId = NaN;
}

Viewing all articles
Browse latest Browse all 10706

Trending Articles