[ws] Notify about player status, options, volume, queue changes

This commit is contained in:
chme 2017-11-01 15:09:37 +01:00 committed by ejurgensen
parent 5cb33189df
commit 4ebc6da0ee

View File

@ -145,6 +145,22 @@ process_notify_request(struct ws_session_data_notify *session_data, void *in, si
{
session_data->events |= LISTENER_SPEAKER;
}
else if (0 == strcmp(event_type, "player"))
{
session_data->events |= LISTENER_PLAYER;
}
else if (0 == strcmp(event_type, "options"))
{
session_data->events |= LISTENER_OPTIONS;
}
else if (0 == strcmp(event_type, "volume"))
{
session_data->events |= LISTENER_VOLUME;
}
else if (0 == strcmp(event_type, "queue"))
{
session_data->events |= LISTENER_QUEUE;
}
}
}
}
@ -193,6 +209,22 @@ send_notify_reply(short events, struct lws* wsi)
{
json_object_array_add(notify, json_object_new_string("outputs"));
}
if (events & LISTENER_PLAYER)
{
json_object_array_add(notify, json_object_new_string("player"));
}
if (events & LISTENER_OPTIONS)
{
json_object_array_add(notify, json_object_new_string("options"));
}
if (events & LISTENER_VOLUME)
{
json_object_array_add(notify, json_object_new_string("volume"));
}
if (events & LISTENER_QUEUE)
{
json_object_array_add(notify, json_object_new_string("queue"));
}
reply = json_object_new_object();
json_object_object_add(reply, "notify", notify);
@ -274,7 +306,8 @@ static struct lws_protocols protocols[] =
static void *
websocket(void *arg)
{
listener_add(listener_cb, LISTENER_UPDATE | LISTENER_PAIRING | LISTENER_SPOTIFY | LISTENER_LASTFM | LISTENER_SPEAKER);
listener_add(listener_cb, LISTENER_UPDATE | LISTENER_PAIRING | LISTENER_SPOTIFY | LISTENER_LASTFM | LISTENER_SPEAKER
| LISTENER_PLAYER | LISTENER_OPTIONS | LISTENER_VOLUME | LISTENER_QUEUE);
while(!ws_exit)
{