jotak / mipod

A node module for exposing an MPD API, either as REST service, Websocket or as a library to include. Written in Typescript, executed in Javascript.
MIT License
17 stars 4 forks source link

Add an optional token on custom command through socket #15

Closed Delapouite closed 9 years ago

Delapouite commented 9 years ago

The same token mecanism used by the search command to match answer when they get back on the client.

jotak commented 9 years ago

Done. Tokens are now Strings rather than Numbers I also improved custom so that it can use a "parser"

For instance: socket.emit("custom", {token: "mytoken", command: "lsinfo \"some path\"", stopper: "\nOK\n"}); will return the exact MPD string

but socket.emit("custom", {token: "mytoken", command: "lsinfo \"some path\"", stopper: "\nOK\n", parser: "entries"}); will return the MPD content parsed as json

or socket.emit("custom", {token: "mytoken", command: "status", parser: "status"}); will return the MPD status parsed as json

(this is not documented yet in readme)

jotak commented 9 years ago

PS, forgot to say: in REST API, custom is now POST