mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-04 00:59:32 +02:00
added stream id
This commit is contained in:
parent
35132bcef8
commit
5dbf4aaaa4
3 changed files with 42 additions and 3 deletions
|
@ -29,6 +29,7 @@ public class ClientInfo implements JsonSerialisable {
|
|||
private Time_t lastSeen;
|
||||
private boolean connected;
|
||||
private int latency = 0;
|
||||
private String stream;
|
||||
private boolean deleted = false;
|
||||
|
||||
public ClientInfo(JSONObject json) {
|
||||
|
@ -45,6 +46,7 @@ public class ClientInfo implements JsonSerialisable {
|
|||
lastSeen = in.readParcelable(Time_t.class.getClassLoader());
|
||||
connected = in.readByte() != 0;
|
||||
latency = in.readInt();
|
||||
stream = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,6 +61,7 @@ public class ClientInfo implements JsonSerialisable {
|
|||
lastSeen = new Time_t(json.getJSONObject("lastSeen"));
|
||||
connected = json.getBoolean("connected");
|
||||
latency = json.getInt("latency");
|
||||
stream = json.getString("stream");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -77,6 +80,7 @@ public class ClientInfo implements JsonSerialisable {
|
|||
json.put("lastSeen", lastSeen);
|
||||
json.put("connected", connected);
|
||||
json.put("latency", latency);
|
||||
json.put("stream", stream);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -133,6 +137,14 @@ public class ClientInfo implements JsonSerialisable {
|
|||
this.latency = latency;
|
||||
}
|
||||
|
||||
public String getStream() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
public void setStream(String stream) {
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return connected;
|
||||
}
|
||||
|
@ -161,6 +173,7 @@ public class ClientInfo implements JsonSerialisable {
|
|||
", lastSeen=" + lastSeen +
|
||||
", connected=" + connected +
|
||||
", latency=" + latency +
|
||||
", stream=" + stream +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
@ -179,6 +192,7 @@ public class ClientInfo implements JsonSerialisable {
|
|||
if (host != null ? !host.equals(that.host) : that.host != null) return false;
|
||||
if (version != null ? !version.equals(that.version) : that.version != null) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
if (stream != null ? !stream.equals(that.stream) : that.stream != null) return false;
|
||||
return !(volume != null ? !volume.equals(that.volume) : that.volume != null);
|
||||
|
||||
}
|
||||
|
@ -194,6 +208,7 @@ public class ClientInfo implements JsonSerialisable {
|
|||
result = 31 * result + (connected ? 1 : 0);
|
||||
result = 31 * result + (deleted ? 1 : 0);
|
||||
result = 31 * result + latency;
|
||||
result = 31 * result + (stream != null ? stream.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -214,6 +229,7 @@ public class ClientInfo implements JsonSerialisable {
|
|||
dest.writeParcelable(lastSeen, flags);
|
||||
dest.writeByte((byte) (connected ? 1 : 0));
|
||||
dest.writeInt(latency);
|
||||
dest.writeString(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,15 @@ public class RemoteControl implements TcpClient.TcpClientListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void setStream(ClientInfo clientInfo, String id) {
|
||||
try {
|
||||
JSONObject request = jsonRequest("Client.SetStream", new JSONObject("{\"client\": \"" + clientInfo.getMac() + "\", \"id\": \"" + id + "\"}"));
|
||||
tcpClient.sendMessage(request.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setVolume(ClientInfo clientInfo, int percent) {
|
||||
try {
|
||||
JSONObject request = jsonRequest("Client.SetVolume", new JSONObject("{\"client\": \"" + clientInfo.getMac() + "\", \"volume\": " + percent + "}"));
|
||||
|
|
|
@ -31,6 +31,7 @@ public class Stream implements JsonSerialisable {
|
|||
private String host;
|
||||
private String path;
|
||||
private String fragment;
|
||||
private String id;
|
||||
private HashMap<String, String> query;
|
||||
|
||||
public Stream(JSONObject json) {
|
||||
|
@ -43,6 +44,7 @@ public class Stream implements JsonSerialisable {
|
|||
host = in.readString();
|
||||
path = in.readString();
|
||||
fragment = in.readString();
|
||||
id = in.readString();
|
||||
Bundle bundle = in.readBundle();
|
||||
query = (HashMap<String, String>)bundle.getSerializable("query");
|
||||
}
|
||||
|
@ -55,6 +57,7 @@ public class Stream implements JsonSerialisable {
|
|||
host = json.getString("host");
|
||||
path = json.getString("path");
|
||||
fragment = json.getString("fragment");
|
||||
id = json.getString("id");
|
||||
query = new HashMap<>();
|
||||
JSONObject jQuery = json.getJSONObject("query");
|
||||
for(int i = 0; i<jQuery.names().length(); i++)
|
||||
|
@ -73,6 +76,7 @@ public class Stream implements JsonSerialisable {
|
|||
json.put("host", host);
|
||||
json.put("path", path);
|
||||
json.put("fragment", fragment);
|
||||
json.put("id", id);
|
||||
JSONObject jQuery = new JSONObject();
|
||||
for (Map.Entry<String, String> entry : query.entrySet())
|
||||
jQuery.put(entry.getKey(), entry.getValue());
|
||||
|
@ -94,10 +98,9 @@ public class Stream implements JsonSerialisable {
|
|||
if (scheme != null ? !scheme.equals(stream.scheme) : stream.scheme != null) return false;
|
||||
if (host != null ? !host.equals(stream.host) : stream.host != null) return false;
|
||||
if (path != null ? !path.equals(stream.path) : stream.path != null) return false;
|
||||
if (fragment != null ? !fragment.equals(stream.fragment) : stream.fragment != null)
|
||||
return false;
|
||||
if (fragment != null ? !fragment.equals(stream.fragment) : stream.fragment != null) return false;
|
||||
if (id != null ? !id.equals(stream.id) : stream.id != null) return false;
|
||||
return !(query != null ? !query.equals(stream.query) : stream.query != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,6 +110,7 @@ public class Stream implements JsonSerialisable {
|
|||
result = 31 * result + (host != null ? host.hashCode() : 0);
|
||||
result = 31 * result + (path != null ? path.hashCode() : 0);
|
||||
result = 31 * result + (fragment != null ? fragment.hashCode() : 0);
|
||||
result = 31 * result + (id != null ? id.hashCode() : 0);
|
||||
result = 31 * result + (query != null ? query.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
@ -151,6 +155,14 @@ public class Stream implements JsonSerialisable {
|
|||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
@ -167,6 +179,7 @@ public class Stream implements JsonSerialisable {
|
|||
", host='" + host + '\'' +
|
||||
", path='" + path + '\'' +
|
||||
", fragment='" + fragment + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", query=" + query +
|
||||
'}';
|
||||
}
|
||||
|
@ -183,6 +196,7 @@ public class Stream implements JsonSerialisable {
|
|||
dest.writeString(host);
|
||||
dest.writeString(path);
|
||||
dest.writeString(fragment);
|
||||
dest.writeString(id);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("query", query);
|
||||
dest.writeBundle(bundle);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue