|
|
@@ -49,7 +49,7 @@ Client.prototype.onData = function(data) {
|
|
|
else if (data.startsWith("STATUS")) {
|
|
|
data = JSON.parse(data.substr("STATUS".length));
|
|
|
if (data) {
|
|
|
- this.status.battery = data.battery || this.status.battery;
|
|
|
+ this.status.battery = data.battery !== undefined ? data.battery :this.status.battery;
|
|
|
this.status.plugged = data.plugged !== undefined ? data.plugged :this.status.plugged;
|
|
|
this.status.volume = data.volume !== undefined ? data.volume :this.status.volume;
|
|
|
this.status.lastUpdate = Date.now();
|
|
|
@@ -115,6 +115,10 @@ Client.prototype.getStatus = function() {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+Client.prototype.setVolume = function(volume) {
|
|
|
+ this.sock.write("SETVOL" +volume +"\n");
|
|
|
+}
|
|
|
+
|
|
|
function onClientConnection(sock) {
|
|
|
var cli = new Client(sock);
|
|
|
if (clients[cli.id])
|