static int server_callback(struct mg_connection *c) { if (c->is_websocket) { c->content[c->content_len] = '\0'; if(c->content_len) return callback_mpd(c); else return MG_CLIENT_CONTINUE; } else return callback_http(c); }
static int server_callback(struct mg_connection *c, enum mg_event ev) { switch(ev) { case MG_CLOSE: mpd_close_handler(c); return MG_TRUE; case MG_REQUEST: if (c->is_websocket) { c->content[c->content_len] = '\0'; if(c->content_len) return callback_mpd(c); else return MG_TRUE; } else #ifdef WITH_DYNAMIC_ASSETS return MG_FALSE; #else return callback_http(c); #endif case MG_AUTH: return MG_TRUE; default: return MG_FALSE; } }
static int server_callback(struct mg_connection *c, enum mg_event ev) { int result = MG_FALSE; FILE *fp = NULL; switch(ev) { case MG_CLOSE: mpd_close_handler(c); return MG_TRUE; case MG_REQUEST: if (c->is_websocket) { c->content[c->content_len] = '\0'; if(c->content_len) return callback_mpd(c); else return MG_TRUE; } else #ifdef WITH_DYNAMIC_ASSETS return MG_FALSE; #else return callback_http(c); #endif case MG_AUTH: // no auth for websockets since mobile safari does not support it if ( (gpass == NULL) || (c->is_websocket) ) return MG_TRUE; else { if ( (fp = fopen(gpass, "r")) != NULL ) { result = mg_authorize_digest(c, fp); fclose(fp); } } return result; default: return MG_FALSE; } }