mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-28 11:50:26 +00:00
Initial websocket connection with mympd version
This commit is contained in:
parent
f119a69b96
commit
290d591c39
@ -77,6 +77,8 @@ void callback_mpd(struct mg_connection *nc, const struct mg_str msg)
|
|||||||
|
|
||||||
switch(cmd_id)
|
switch(cmd_id)
|
||||||
{
|
{
|
||||||
|
case MPD_API_WELCOME:
|
||||||
|
n = mympd_put_welcome(mpd.buf);
|
||||||
case MPD_API_UPDATE_DB:
|
case MPD_API_UPDATE_DB:
|
||||||
mpd_run_update(mpd.conn, NULL);
|
mpd_run_update(mpd.conn, NULL);
|
||||||
break;
|
break;
|
||||||
@ -767,6 +769,18 @@ int mpd_put_state(char *buffer, int *current_song_id, int *next_song_id, unsign
|
|||||||
return cur - buffer;
|
return cur - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mympd_put_welcome(char *buffer)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
len = snprintf(buffer, MAX_SIZE,
|
||||||
|
"{\"type\":\"welcome\", \"data\":{"
|
||||||
|
"\"version\":\"%s\"}}",
|
||||||
|
MYMPD_VERSION
|
||||||
|
);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
int mympd_put_settings(char *buffer)
|
int mympd_put_settings(char *buffer)
|
||||||
{
|
{
|
||||||
struct mpd_status *status;
|
struct mpd_status *status;
|
||||||
|
@ -84,7 +84,8 @@
|
|||||||
X(MPD_API_GET_ARTISTALBUMS) \
|
X(MPD_API_GET_ARTISTALBUMS) \
|
||||||
X(MPD_API_GET_ARTISTALBUMTITLES) \
|
X(MPD_API_GET_ARTISTALBUMTITLES) \
|
||||||
X(MPD_API_GET_ARTISTS) \
|
X(MPD_API_GET_ARTISTS) \
|
||||||
X(MPD_API_GET_CURRENT_SONG)
|
X(MPD_API_GET_CURRENT_SONG) \
|
||||||
|
X(MPD_API_WELCOME)
|
||||||
|
|
||||||
enum mpd_cmd_ids {
|
enum mpd_cmd_ids {
|
||||||
MPD_CMDS(GEN_ENUM)
|
MPD_CMDS(GEN_ENUM)
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
//#include <pthread.h>
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
#include "mongoose/mongoose.h"
|
#include "mongoose/mongoose.h"
|
||||||
@ -59,10 +58,7 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stdout,"New Websocket connection\n");
|
fprintf(stdout,"New Websocket connection\n");
|
||||||
#endif
|
#endif
|
||||||
struct mg_str d = {(char *) "MPD_API_GET_SETTINGS", 20 };
|
struct mg_str d = {(char *) "MPD_API_WELCOME" };
|
||||||
callback_mpd(nc, d);
|
|
||||||
d.p="MPD_API_GET_OUTPUTS";
|
|
||||||
d.len=19;
|
|
||||||
callback_mpd(nc, d);
|
callback_mpd(nc, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user