mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-27 11:20:26 +00:00
Merge branch 'master' into devel
This commit is contained in:
commit
76ab27f30b
@ -42,6 +42,7 @@ Dependencies
|
||||
- libmpdclient 2: http://www.musicpd.org/libs/libmpdclient/
|
||||
- cmake 2.6: http://cmake.org/
|
||||
- OpenSSL: https://www.openssl.org/
|
||||
- libasan3 (for debug builds only)
|
||||
|
||||
Unix Build Instructions
|
||||
-----------------------
|
||||
|
4
htdocs/css/bootstrap.min.css
vendored
4
htdocs/css/bootstrap.min.css
vendored
File diff suppressed because one or more lines are too long
@ -170,8 +170,7 @@ function appRoute() {
|
||||
}
|
||||
else if (app.current.app == 'Queue' ) {
|
||||
document.getElementById('QueueList').classList.add('opacity05');
|
||||
/*
|
||||
if (app.last.app != app.current.app) {
|
||||
/* if (app.last.app != app.current.app) {
|
||||
if (app.current.search.length < 2) {
|
||||
setPagination(app.current.page);
|
||||
}
|
||||
@ -245,7 +244,6 @@ function appRoute() {
|
||||
'<td colspan="5">Searching...</td></tr>';
|
||||
// else
|
||||
// setPagination(app.current.page);
|
||||
|
||||
// document.getElementById('searchstr').value = app.current.search;
|
||||
}
|
||||
|
||||
@ -599,6 +597,7 @@ function parseStats(obj) {
|
||||
|
||||
function toggleBtn(btn, state) {
|
||||
var b = document.getElementById(btn);
|
||||
if (!b) return;
|
||||
if (state == undefined)
|
||||
state = b.classList.contains('active') ? 0 : 1;
|
||||
if (state == 1) {
|
||||
@ -784,11 +783,7 @@ function getQueue() {
|
||||
if (app.current.search.length >= 2)
|
||||
sendAPI({"cmd": "MPD_API_SEARCH_QUEUE", "data": {"mpdtag":app.current.filter, "offset":app.current.page, "searchstr": app.current.search}}, parseQueue);
|
||||
else {
|
||||
var queue_version = document.getElementById('QueueList').getAttribute('data-version');
|
||||
if (last_state && queue_version != last_state.data.queue_version)
|
||||
sendAPI({"cmd": "MPD_API_GET_QUEUE", "data": {"offset": app.current.page}}, parseQueue);
|
||||
else
|
||||
document.getElementById('QueueList').classList.remove('opacity05');
|
||||
sendAPI({"cmd": "MPD_API_GET_QUEUE", "data": {"offset": app.current.page}}, parseQueue);
|
||||
}
|
||||
}
|
||||
|
||||
|
5
htdocs/js/mpd.min.js
vendored
5
htdocs/js/mpd.min.js
vendored
@ -40,7 +40,7 @@ function webSocketConnect(){socket=new WebSocket(getWsUrl());try{socket.onopen=f
|
||||
break;case "update_queue":"Queue"===app.current.app&&getQueue();break;case "song_change":songChange(b);break;case "error":showNotification(b.data,"","","danger")}}},socket.onclose=function(){console.log("disconnected");modalConnectionError.show();setTimeout(function(){console.log("reconnect");webSocketConnect()},3E3)}}catch(a){alert("Error: "+a)}}
|
||||
function getWsUrl(){var a=document.URL;if("https"==a.substring(0,5)){var b="wss://";a=a.substr(8)}else b="ws://","http"==a.substring(0,4)&&(a=a.substr(7));a=a.split("#");var c=/\/$/.test(a[0])?"":"/";return b+a[0]+c+"ws"}
|
||||
function parseStats(a){document.getElementById("mpdstats_artists").innerText=a.data.artists;document.getElementById("mpdstats_albums").innerText=a.data.albums;document.getElementById("mpdstats_songs").innerText=a.data.songs;document.getElementById("mpdstats_dbplaytime").innerText=beautifyDuration(a.data.dbplaytime);document.getElementById("mpdstats_playtime").innerText=beautifyDuration(a.data.playtime);document.getElementById("mpdstats_uptime").innerText=beautifyDuration(a.data.uptime);var b=new Date(1E3*
|
||||
a.data.dbupdated);document.getElementById("mpdstats_dbupdated").innerText=b.toUTCString();document.getElementById("mympdVersion").innerText=a.data.mympd_version;document.getElementById("mpdVersion").innerText=a.data.mpd_version}function toggleBtn(a,b){a=document.getElementById(a);void 0==b&&(b=a.classList.contains("active")?0:1);1==b?(a.classList.add("active"),a.setAttribute("aria-pressed","true")):(a.classList.remove("active"),a.setAttribute("aria-pressed","false"))}
|
||||
a.data.dbupdated);document.getElementById("mpdstats_dbupdated").innerText=b.toUTCString();document.getElementById("mympdVersion").innerText=a.data.mympd_version;document.getElementById("mpdVersion").innerText=a.data.mpd_version}function toggleBtn(a,b){if(a=document.getElementById(a))void 0==b&&(b=a.classList.contains("active")?0:1),1==b?(a.classList.add("active"),a.setAttribute("aria-pressed","true")):(a.classList.remove("active"),a.setAttribute("aria-pressed","false"))}
|
||||
function parseSettings(a){toggleBtn("btnRandom",a.data.random);toggleBtn("btnConsume",a.data.consume);toggleBtn("btnSingle",a.data.single);toggleBtn("btnRepeat",a.data.repeat);void 0!=a.data.crossfade?(document.getElementById("inputCrossfade").removeAttribute("disabled"),document.getElementById("inputCrossfade").value=a.data.crossfade):document.getElementById("inputCrossfade").setAttribute("disabled","disabled");void 0!=a.data.mixrampdb?(document.getElementById("inputMixrampdb").removeAttribute("disabled"),
|
||||
document.getElementById("inputMixrampdb").value=a.data.mixrampdb):document.getElementById("inputMixrampdb").setAttribute("disabled","disabled");void 0!=a.data.mixrampdelay?(document.getElementById("inputMixrampdelay").removeAttribute("disabled"),document.getElementById("inputMixrampdelay").value=a.data.mixrampdelay):document.getElementById("inputMixrampdelay").setAttribute("disabled","disabled");document.getElementById("selectReplaygain").value=a.data.replaygain;var b=document.getElementById("btnnotifyWeb");
|
||||
notificationsSupported()?a.data.notificationWeb?(toggleBtn("btnnotifyWeb",a.data.notificationWeb),Notification.requestPermission(function(b){"permission"in Notification||(Notification.permission=b);"granted"===b?toggleBtn("btnnotifyWeb",1):(toggleBtn("btnnotifyWeb",0),a.data.notificationWeb=0)})):toggleBtn("btnnotifyWeb",0):(b.setAttribute("disabled","disabled"),toggleBtn("btnnotifyWeb",0));toggleBtn("btnnotifyPage",a.data.notificationPage);settings=a.data;settings.mpdstream="http://";settings.mpdstream=
|
||||
@ -50,8 +50,7 @@ function parseState(a){if(JSON.stringify(a)!==JSON.stringify(last_state)){1==a.d
|
||||
0==a.data.queue_length?domCache.btnPlay.setAttribute("disabled","disabled"):domCache.btnPlay.removeAttribute("disabled");-1==a.data.volume?(domCache.volumePrct.innerText("Volumecontrol disabled"),domCache.volumeControl.classList.add("hide")):(domCache.volumeControl.classList.remove("hide"),domCache.volumePrct.innerText=a.data.volume+" %",domCache.volumeIcon.innerText=0==a.data.volume?"volume_off":50>a.data.volume?"volume_down":"volume_up");domCache.volumeBar.value=a.data.volume;current_song.totalTime=
|
||||
a.data.totalTime;current_song.currentSongId=a.data.currentsongid;var b=Math.floor(a.data.totalTime/60),c=a.data.totalTime-60*b,e=Math.floor(a.data.elapsedTime/60),d=a.data.elapsedTime-60*e;domCache.progressBar.value=Math.floor(100*a.data.elapsedTime/a.data.totalTime);b=e+":"+(10>d?"0":"")+d+" / "+b+":"+(10>c?"0":"")+c;domCache.counter.innerText=b;last_state&&(c=document.getElementById("queueTrackId"+last_state.data.currentsongid))&&(e=c.getElementsByTagName("td"),e[4].innerText=c.getAttribute("data-duration"),
|
||||
e[0].classList.remove("material-icons"),e[0].innerText=c.getAttribute("data-songpos"),c.classList.remove("font-weight-bold"));if(c=document.getElementById("queueTrackId"+a.data.currentsongid))e=c.getElementsByTagName("td"),e[4].innerText=b,e[0].classList.add("material-icons"),e[0].innerText="play_arrow",c.classList.add("font-weight-bold");void 0!=last_state&&a.data.queue_version==last_state.data.queue_version||sendAPI({cmd:"MPD_API_GET_CURRENT_SONG"},songChange);b=a.data.outputs.length;for(c=0;c<
|
||||
b;c++)toggleBtn("btnoutput"+a.data.outputs[c].id,a.data.outputs[c].state);last_state=a}}
|
||||
function getQueue(){if(2<=app.current.search.length)sendAPI({cmd:"MPD_API_SEARCH_QUEUE",data:{mpdtag:app.current.filter,offset:app.current.page,searchstr:app.current.search}},parseQueue);else{var a=document.getElementById("QueueList").getAttribute("data-version");last_state&&a!=last_state.data.queue_version?sendAPI({cmd:"MPD_API_GET_QUEUE",data:{offset:app.current.page}},parseQueue):document.getElementById("QueueList").classList.remove("opacity05")}}
|
||||
b;c++)toggleBtn("btnoutput"+a.data.outputs[c].id,a.data.outputs[c].state);last_state=a}}function getQueue(){2<=app.current.search.length?sendAPI({cmd:"MPD_API_SEARCH_QUEUE",data:{mpdtag:app.current.filter,offset:app.current.page,searchstr:app.current.search}},parseQueue):sendAPI({cmd:"MPD_API_GET_QUEUE",data:{offset:app.current.page}},parseQueue)}
|
||||
function parseQueue(a){if("Queue"===app.current.app){0<a.totalTime?document.getElementById("panel-heading-queue").innerText=a.totalEntities+" Songs \u2013 "+beautifyDuration(a.totalTime):0<a.totalEntities?document.getElementById("panel-heading-queue").innerText=a.totalEntities+" Songs":document.getElementById("panel-heading-queue").innerText="";var b=a.data.length,c=document.getElementById(app.current.app+"List");c.setAttribute("data-version",a.queue_version);c=c.getElementsByTagName("tbody")[0];
|
||||
for(var e=c.getElementsByTagName("tr"),d=0;d<b;d++)if(!e[d]||e[d].getAttribute("data-trackid")!=a.data[d].id){var f=Math.floor(a.data[d].duration/60),g=a.data[d].duration-60*f;f=f+":"+(10>g?"0":"")+g;g=document.createElement("tr");g.setAttribute("data-trackid",a.data[d].id);g.setAttribute("id","queueTrackId"+a.data[d].id);g.setAttribute("data-songpos",a.data[d].pos+1);g.setAttribute("data-duration",f);g.setAttribute("data-uri",a.data[d].uri);g.innerHTML="<td>"+(a.data[d].pos+1)+"</td><td>"+a.data[d].title+
|
||||
"</td><td>"+a.data[d].artist+"</td><td>"+a.data[d].album+"</td><td>"+f+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';d<e.length?e[d].replaceWith(g):c.append(g)}for(d=e.length-1;d>=b;d--)e[d].remove();"queuesearch"==a.type&&0==b?c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="5">No results, please refine your search!</td></tr>':"queue"==a.type&&0==b&&(c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="5">Empty queue</td></tr>');
|
||||
|
@ -121,7 +121,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
}
|
||||
free(p_charbuf1);
|
||||
}
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"result\", \"data\": \"ok\"}");
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_GET_ARTISTALBUMTITLES:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { albumartist:%Q, album:%Q } }", &p_charbuf1, &p_charbuf2);
|
||||
@ -136,34 +136,45 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
break;
|
||||
case MPD_API_UPDATE_DB:
|
||||
mpd_run_update(mpd.conn, NULL);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_SET_PAUSE:
|
||||
mpd_run_toggle_pause(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_SET_PREV:
|
||||
mpd_run_previous(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_SET_NEXT:
|
||||
mpd_run_next(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_SET_PLAY:
|
||||
mpd_run_play(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_SET_STOP:
|
||||
mpd_run_stop(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_RM_ALL:
|
||||
mpd_run_clear(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_RM_TRACK:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { track:%u } }", &uint_buf1);
|
||||
if (je == 1)
|
||||
if (je == 1) {
|
||||
mpd_run_delete_id(mpd.conn, uint_buf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_RM_RANGE:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { start:%u, end:%u } }", &uint_buf1, &uint_buf2);
|
||||
if (je == 2)
|
||||
if (je == 2) {
|
||||
mpd_run_delete_range(mpd.conn, uint_buf1, uint_buf2);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_MOVE_TRACK:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { track:%u, pos:%u } }", &uint_buf1, &uint_buf2);
|
||||
@ -171,40 +182,48 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
uint_buf1 -= 1;
|
||||
uint_buf2 -= 1;
|
||||
mpd_run_move(mpd.conn, uint_buf1, uint_buf2);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_PLAY_TRACK:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { track:%u } }", &uint_buf1);
|
||||
if (je == 1)
|
||||
if (je == 1) {
|
||||
mpd_run_play_id(mpd.conn, uint_buf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_GET_OUTPUTNAMES:
|
||||
n = mympd_put_outputnames(mpd.buf);
|
||||
break;
|
||||
case MPD_API_TOGGLE_OUTPUT:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { output:%u, state:%u } }", &uint_buf1, &uint_buf2);
|
||||
if (je == 2)
|
||||
{
|
||||
if (je == 2) {
|
||||
if (uint_buf2)
|
||||
mpd_run_enable_output(mpd.conn, uint_buf1);
|
||||
else
|
||||
mpd_run_disable_output(mpd.conn, uint_buf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_SET_VOLUME:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { volume:%u } }", &uint_buf1);
|
||||
if (je == 1)
|
||||
if (je == 1) {
|
||||
mpd_run_set_volume(mpd.conn, uint_buf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_SET_SEEK:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { songid:%u, seek:%u } }", &uint_buf1, &uint_buf2);
|
||||
if (je == 2)
|
||||
if (je == 2) {
|
||||
mpd_run_seek_id(mpd.conn, uint_buf1, uint_buf2);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_GET_QUEUE:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { offset:%u } }", &uint_buf1);
|
||||
if (je == 1)
|
||||
if (je == 1) {
|
||||
n = mympd_put_queue(mpd.buf, uint_buf1);
|
||||
}
|
||||
break;
|
||||
case MPD_API_GET_CURRENT_SONG:
|
||||
n = mympd_put_current_song(mpd.buf);
|
||||
@ -251,6 +270,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
if (je == 2) {
|
||||
mpd_run_add_id_to(mpd.conn, p_charbuf1, uint_buf1);
|
||||
free(p_charbuf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_REPLACE_TRACK:
|
||||
@ -260,6 +280,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
mpd_run_add(mpd.conn, p_charbuf1);
|
||||
free(p_charbuf1);
|
||||
mpd_run_play(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_ADD_TRACK:
|
||||
@ -267,6 +288,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
if (je == 1) {
|
||||
mpd_run_add(mpd.conn, p_charbuf1);
|
||||
free(p_charbuf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_ADD_PLAY_TRACK:
|
||||
@ -276,6 +298,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
if(int_buf != -1)
|
||||
mpd_run_play_id(mpd.conn, int_buf);
|
||||
free(p_charbuf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_REPLACE_PLAYLIST:
|
||||
@ -285,6 +308,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
mpd_run_load(mpd.conn, p_charbuf1);
|
||||
free(p_charbuf1);
|
||||
mpd_run_play(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_ADD_PLAYLIST:
|
||||
@ -292,6 +316,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
if (je == 1) {
|
||||
mpd_run_load(mpd.conn, p_charbuf1);
|
||||
free(p_charbuf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_SAVE_QUEUE:
|
||||
@ -299,6 +324,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
if (je == 1) {
|
||||
mpd_run_save(mpd.conn, p_charbuf1);
|
||||
free(p_charbuf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_SEARCH_QUEUE:
|
||||
@ -327,6 +353,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
break;
|
||||
case MPD_API_SEND_SHUFFLE:
|
||||
mpd_run_shuffle(mpd.conn);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
break;
|
||||
case MPD_API_SEND_MESSAGE:
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { channel:%Q, text:%Q } }", &p_charbuf1, &p_charbuf2);
|
||||
@ -334,6 +361,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
mpd_run_send_message(mpd.conn, p_charbuf1, p_charbuf2);
|
||||
free(p_charbuf1);
|
||||
free(p_charbuf2);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_RM_PLAYLIST:
|
||||
@ -341,6 +369,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
if (je == 1) {
|
||||
mpd_run_rm(mpd.conn, p_charbuf1);
|
||||
free(p_charbuf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_GET_SETTINGS:
|
||||
@ -355,7 +384,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
if (mpd.conn_state == MPD_CONNECTED && mpd_connection_get_error(mpd.conn) != MPD_ERROR_SUCCESS)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"Error: %s\n",mpd_connection_get_error_message(mpd.conn));
|
||||
fprintf(stderr,"Error: %s\n", mpd_connection_get_error_message(mpd.conn));
|
||||
#endif
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"error\", \"data\": \"%s\"}",
|
||||
mpd_connection_get_error_message(mpd.conn));
|
||||
@ -365,19 +394,20 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
mpd.conn_state = MPD_FAILURE;
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
if (is_websocket(nc)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"Send websocket response:\n %s\n",mpd.buf);
|
||||
#endif
|
||||
mg_send_websocket_frame(nc, WEBSOCKET_OP_TEXT, mpd.buf, n);
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"Send http response:\n %s\n",mpd.buf);
|
||||
#endif
|
||||
mg_send_http_chunk(nc, mpd.buf, n);
|
||||
}
|
||||
if (n == 0)
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"error\", \"data\": \"No response for cmd %s\"}", cmd);
|
||||
|
||||
if (is_websocket(nc)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"Send websocket response:\n %s\n",mpd.buf);
|
||||
#endif
|
||||
mg_send_websocket_frame(nc, WEBSOCKET_OP_TEXT, mpd.buf, n);
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"Send http response:\n %s\n",mpd.buf);
|
||||
#endif
|
||||
mg_send_http_chunk(nc, mpd.buf, n);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user